How do I get a UTC Timestamp from Calendar?

前端 未结 4 935
慢半拍i
慢半拍i 2021-02-07 19:56

In Java when I use Calendar.getInstance(); I get a Calendar object for the current Timezone. But java.sql.Timestamp is usually stored in U

4条回答
  •  后悔当初
    2021-02-07 20:03

    Following snippet should satisfy your requirements:

    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    

提交回复
热议问题