To get the end time of the day.
Date now = new Date();
now.setHours(23);
now.setMinutes(59);
now.setSeconds(59);
To get the stat time of the day.
Date now = new Date();
now.setHours(00);
now.setMinutes(00);
now.setSeconds(00);
To get the end time of the day.
Date now = new Date();
now.setHours(23);
now.setMinutes(59);
now.setSeconds(59);
To get the stat time of the day.
Date now = new Date();
now.setHours(00);
now.setMinutes(00);
now.setSeconds(00);
Date.set()
methods are deprecated. Use Calendar
instead.
Calendar cal = Calendar.getInstance();
Calendar start = new GregorianCalendar(cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
Calendar end = new GregorianCalendar(cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
CLARIFICATION: A day does not end at 23:59:59. The above code just creates two Calendar
instances, one set at 0:00:00 and the other one at 23:59:59 of the current day.