I want to set a string containing the new current date and time 00:00:00. I wrote the following code, but the time is set to12:00:00
Calendar 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);
String today1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").
format(calendar.getTime())
I would really like to know why the code does not work or, alternatively, get another way to set the time to 00:00:00
source
share