Seymour Cakes Seymour Cakes - 4 months ago 5
Java Question

Is there an easier way to get start of current day time than this?

I basically want to get zero or beginning hour for currrent day.

def today = Calendar.instance
today.set(Calendar.HOUR_OF_DAY, 0)
today.set(Calendar.MINUTE, 0)
today.set(Calendar.SECOND, 0)
println today // Mon Mar 15 00:00:00 SGT 2010


Not simpler than the other solutions, but less lines:

def now = new GregorianCalendar()
def today = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH))
println today.getTime()