Created
September 28, 2021 02:18
-
-
Save punkmonday/b1a7a113012b6e77e673115dce8fa7dc to your computer and use it in GitHub Desktop.
datetime converter by a spec pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.agk.voice.util; | |
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
public class DateUtil { | |
public static String processDate(String dateTime) { | |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy"); | |
LocalDateTime localDateTime = LocalDateTime.parse(dateTime, dateTimeFormatter); | |
return localDateTime.toString(); | |
} | |
public static void main(String[] args) { | |
String dateTime = "Fri Aug 06 14:51:14 CST 2021"; | |
System.out.println(DateUtil.processDate(dateTime)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment