Oracle / JDBC: retrieving TIMESTAMP WITH TIME ZONE value in ISO 8601 format

前端 未结 7 1985
抹茶落季
抹茶落季 2020-12-13 10:58

A lot have been said (and written on SO) on parts of the subject, but not in a comprehensive, complete way, so we can have one \"ultimate, covering-it-all\" solution for eve

7条回答
  •  被撕碎了的回忆
    2020-12-13 11:21

    you need two values: time utc in millis since 1970 and timezone offset fom utc.
    So store them as a pair and forward them as a pair.

    class DateWithTimeZone {
    long timestampUtcMillis;
    // offset in seconds
    int tzOffsetUtcSec;
    }
    

    A Date is a pair of numbers. It is not a String. So a machine interface should not contain a date represented by a iso string, although that is handy to debug. If even java cannot parse that iso date, how do you think that your clients can do?

    If you design an interface to your clients, think how they can parse that. And in advance write a code that shows that.

提交回复
热议问题