We would like to know how to format date as form of Jun 22, 2015 2:08 PM.
import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; //w w w .java 2s . c o m public class Main { public static void main(String[] args) { DateTimeFormatter dateTimeFormatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT); System.out.println(dateTimeFormatter.format(LocalDateTime.now())); } }
The code above generates the following result.