noTime in TimeHelpers

6 views
Skip to first unread message

James K

unread,
Jun 22, 2011, 1:19:07 PM6/22/11
to Lift
I might have the purpose of this function wrong but I assumed that the
noTime function when run on a Date would strip off the hours, minutes,
seconds and milliseconds.

/** This class adds a noTime method the Date class, in order to get
at Date object starting at 00:00 */
class DateExtension(date: Date) {
/** @returns a Date object starting at 00:00 from date */
def noTime = {
---> val calendar = Calendar.getInstance
calendar.set(Calendar.HOUR_OF_DAY, 0)
calendar.set(Calendar.MINUTE, 0)
calendar.set(Calendar.SECOND, 0)
calendar.set(Calendar.MILLISECOND, 0)
calendar.getTime
}
}

When I tried to use it on a date I had created e.g. myDate.noTime, it
always returned the today's date without the hours etc instead of the
date I had used.

Should the next line after the one I've indicated be
calendar.setTime(date)

Or is the function only supposed to return today's date?

Derek Chen-Becker

unread,
Jun 22, 2011, 1:29:36 PM6/22/11
to lif...@googlegroups.com
Looks like a bug to me. Please open a ticket.

Derek


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


Reply all
Reply to author
Forward
0 new messages