日期格式处理EEE MMM dd HH:mm:ss 'GMT'zz yyyy

 String dateTimeString = "Sun Mar 12 01:01:01 GMT+08:00 2023";
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.appendPattern("EEE MMM dd HH:mm:ss 'GMT'zz yyyy")
.toFormatter().withLocale(Locale.ENGLISH);

try {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateTimeString, formatter);
System.out.println("Parsed ZonedDateTime: " + zonedDateTime);
} catch (DateTimeParseException e) {
System.err.println("Error parsing date: " + e.getMessage());
}
posted @ 2024-04-02 10:27  life_start  阅读(50)  评论(0编辑  收藏  举报