How to set time on a date object in java

I created a Date object in Java. When I do this, it shows something like: date=Tue Aug 09 00:00:00 IST 2011 . As a result, it seems that my Excel file is one day smaller (February 27 becomes February 26, etc.). I think it should be due to time. How can I tune it at about 5:30 pm?

+60
java date datetime calendar
Mar 02 2018-11-11T00:
source share
2 answers
 Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY,17); cal.set(Calendar.MINUTE,30); cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); Date d = cal.getTime(); 

see also

+137
Mar 02 2018-11-11T00:
source share

Can you show the code that you use to set the date object? In any case, <you can use this code to initialize the date:

 new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2011-01-01 00:00:00") 
+16
Mar 02 '11 at 9:23
source share



All Articles