Hello,

I've extended MappedDateTime to override _toForm (to add a
class="datepicker") and set my own DateFormat for the input/output.
This is so that I could use a JQuerry datepicker which allows me to
set the time as well as the date.  Everything is working on the
client, and the date with time is sent to the server fine, but upon
retrieval from the database time is being lost.

08/25/2009 01:45 pm is what _toForm got sent from the form
08/25/2009 12:00 AM is what asHtml is printing back out.  Time is
always 12:00 AM

To me, it looks as if the date is having the time stripped off the
long value of the Date.  Looking in the MappedDateTime source, I don't
see anything that looks like it affects the long value of the Date
other than toLong, which appears to only be used by asJsExp.  (To be
sure I've overwritten toLong with no affect.)

MappedDateTime converts the Date into a Timestamp for the database to
store.  I know there are issues with Timestamp stripping off nanos,
but I've never heard of them stripping off hours also.

Any help would be appreciated.  Thank You!


------------------------------------------------ Example source
follows:

class MyMappedDateTime[T<:Mapper[T]](owner: T) extends MappedDateTime
[T](owner) {
...

// _toForm
override def _toForm: Box[NodeSeq] =
  S.fmapFunc( {s: List[String] => printDateFormatter.parse(s(0))} )
{ funcName =>
    Full(<input type='text' class={classValue} id={fieldId} name=
{funcName}
      value={is match {case null => "" case s => printDate(s)}}/>)
}

// asHtml
override def asHtml: Node = Text(is match {case null => "" case s =>
printDate(s)})

//date format:
val printDateFormatter = new SimpleDateFormat("MM/dd/yyyy hh:mm aa")

// format a given Date
def printDate(in: Date) : String = printDateFormatter.format(in)
...
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to