java - How to get today's Date? -
in other words, want functionality provides joda-time:
today = today.withtime(0, 0, 0, 0);
but without joda-time, java.util.date.
methods such .sethours() , etc. deprecated. there more correct way?
date today = new date(); today.sethours(0); //same minutes , seconds
since methods deprecated, can calendar
:
calendar today = calendar.getinstance(); today.set(calendar.hour_of_day, 0); // same minutes , seconds
and if need date
object in end, call today.gettime()
Comments
Post a Comment