Java Time Zone When Parsing DateFormat

后端 未结 7 1669
梦谈多话
梦谈多话 2020-12-06 17:20

I had code that parses date as follows:

String ALT_DATE_TIME_FORMAT = \"yyyy-MM-dd\'T\'HH:mm:ss.SSSZ\";
SimpleDateFormat sdf = new SimpleDateFormat(
                 


        
7条回答
  •  失恋的感觉
    2020-12-06 17:52

    The question should be where requiredTimeStamp is coming from and in which format. Is it entered by a user, or read from another program? Which component creates the date in the String representation?

    The format "2010-12-27T10:50:44.000-08:00" looks like standardized format ISO-8601 It should be parseable with the pattern yyyy-MM-dd'T'HH:mm:ss.SSSZ

    Not sure which settings affect this, but there is an Oracle FAQ about Java TimeZones. It may be user.timezone system property or the /etc/localtime symlink in RHEL.

提交回复
热议问题