problems with Java daylight savings time

后端 未结 4 1135
长情又很酷
长情又很酷 2021-01-05 01:35

I have a Java app that needs to be cognizant of the time zone. When I take a Unix epoch time and try to convert it into a timestamp to use for an Oracle SQL call, it is get

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 02:22

    I have found a way to ensure the daylight saving is ignored

    TimeZone tz = TimeZone.getTimeZone("GMT");
    TimeZone.setDefault(tz);
    GregorianCalendar calendar;
    calendar = new GregorianCalendar();
    

    Set the timezone before you create your GregorianCalendar object

提交回复
热议问题