Skip to content

Instantly share code, notes, and snippets.

@punkmonday
Created September 28, 2021 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punkmonday/b1a7a113012b6e77e673115dce8fa7dc to your computer and use it in GitHub Desktop.
Save punkmonday/b1a7a113012b6e77e673115dce8fa7dc to your computer and use it in GitHub Desktop.
datetime converter by a spec pattern
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