Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package day4HomeWork;
  2.  
  3. import java.time.*;
  4. import java.time.format.DateTimeFormatter;
  5. import java.time.format.FormatStyle;
  6.  
  7. public class DataTime {
  8.  
  9.     public static void main(String[] args) {
  10.         LocalDateTime currentDateTime = LocalDateTime.now();
  11.  
  12.         DateTimeFormatter format1 = DateTimeFormatter.ofPattern("EEEE, dd/MM/yyyy hh:mm a");
  13.         String formatDateTime = currentDateTime.format(format1);
  14.         System.out.println(formatDateTime);
  15.  
  16.         DateTimeFormatter format2 = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
  17.         String formatDateTime2 = currentDateTime.format(format2);
  18.         System.out.println(formatDateTime2);
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement