Java LocalDateTime format as February 21, 2018 12:57 PM

Description

Java LocalDateTime format as February 21, 2018 12:57 PM

// Create a custom date and time format. 
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String args[]) {

    LocalDateTime curDateTime = LocalDateTime.now();
    System.out.println(curDateTime.format(DateTimeFormatter.ofPattern("MMMM d',' yyyy h':'mm a")));
  }/* w w w. ja  va 2s .c  o  m*/
}



PreviousNext

Related