How do I display a date with a custom timezone?

后端 未结 4 1497
闹比i
闹比i 2021-02-13 09:28

Lets say I have a string that represents a date that looks like this:

\"Wed Jul 08 17:08:48 GMT 2009\"

So I parse that string into a date object like this:

4条回答
  •  萌比男神i
    2021-02-13 09:40

    Using:

    formatter.setTimeZone(TimeZone.getTimeZone("US/Central"));
    

    outputs:

    Wed Jul 08 12:08:48 CDT 2009
    

    for the date in your example on my machine. That is after substituting zzz for ZZZ in the format string.

提交回复
热议问题