Joda DateTime to Timestamp conversion

后端 未结 4 1217
离开以前
离开以前 2020-12-23 16:37

I am trying to change the value of Timestamp by DateTimeZone in Joda :

  DateTime dt = new DateTime(rs.getTimestamp(\"anyt         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-23 17:29

    I've solved this problem in this way.

    String dateUTC = rs.getString("date"); //UTC
    DateTime date;
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS").withZoneUTC();
    date = dateTimeFormatter.parseDateTime(dateUTC);
    

    In this way you ignore the server TimeZone forcing your chosen TimeZone.

提交回复
热议问题