Java – what happened to “2017-9-21 23:59”?
•
Java
I used a calender for one minute at a time But something strange happened on the date of "2017-9-21 23:59" The date came back an hour It acts like a date to save time, but save time dates must not occur
This is my code and output:
GregorianCalendar fromCalendar = new GregorianCalendar(2017,8,21,22,58); for (int i = 0; i < 120; i++) { System.out.println(fromCalendar.get(Calendar.YEAR) + "-" + (fromCalendar.get(Calendar.MONTH) + 1) + "-" + fromCalendar.get(Calendar.DAY_OF_MONTH) + " " + fromCalendar.get(Calendar.HOUR_OF_DAY) + ":" + fromCalendar.get(Calendar.MINUTE) + " "); fromCalendar.add(Calendar.MINUTE,1); }
Output:
. . . 2017-9-21 23:58 2017-9-21 23:59 2017-9-21 23:0 2017-9-21 23:1 2017-9-21 23:2 . . .
Is there any simple point I misunderstood?
Solution
According to the timeanddate Com DST page, there is only one country in the world whose DST conversion takes place in Iran at 00:00 on September 22, 2017
Therefore, you must use the timezone for Iran: Asia / Tehran
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码