DateTimeFormatter 内部已经定义了一些日期时间格式化,如果没有特殊需求可以考虑使用这些.
Formatter | Example |
---|---|
BASIC_ISO_DATE | ‘20181203’ |
ISO_LOCAL_DATE | ‘2018-12-03’ |
ISO_OFFSET_DATE | ‘2018-12-03+01:00’ |
ISO_DATE | ‘2018-12-03+01:00’; ‘2018-12-03’ |
ISO_LOCAL_TIME | ‘11:15:30’ |
ISO_OFFSET_TIME | ‘11:15:30+01:00’ |
ISO_TIME | ‘11:15:30+01:00’; ‘11:15:30’ |
ISO_LOCAL_DATE_TIME | ‘2018-12-03T11:15:30’ |
ISO_OFFSET_DATE_TIME | ‘2018-12-03T11:15:30+01:00’ |
ISO_ZONED_DATE_TIME | ‘2018-12-03T11:15:30+01:00[Europe/Paris]’ |
ISO_DATE_TIME | ‘2018-12-03T11:15:30+01:00[Europe/Paris]’ |
ISO_ORDINAL_DATE | ‘2018-337’ |
ISO_WEEK_DATE | ‘2018-W48-6’ |
ISO_INSTANT | ‘2018-12-03T11:15:30Z’ |
RFC_1123_DATE_TIME | ‘Tue, 3 Jun 2018 11:05:30 GMT’ |