James K
unread,Jun 22, 2011, 1:19:07 PM6/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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?