SHARE
TWEET

Untitled

a guest Feb 16th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.time.LocalDate;
  2. import java.time.OffsetDateTime;
  3. import java.time.OffsetTime;
  4. import java.time.ZoneId;
  5. import java.time.format.DateTimeFormatter;
  6. import java.time.format.FormatStyle;
  7.  
  8. public class DateTimeFormat
  9. {
  10.   public static void main(String[] args)
  11.   {
  12.     LocalDate todayDate = LocalDate.of(2020, 2, 16);
  13.     System.out.println(todayDate);
  14.     System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).format(todayDate));
  15.     System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).format(todayDate));
  16.     System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(todayDate));
  17.     System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).format(todayDate));
  18.  
  19.     System.out.println(DateTimeFormatter.ISO_LOCAL_DATE.format(LocalDate.of(2020, 2, 16)));
  20.     System.out.println(DateTimeFormatter.ISO_OFFSET_DATE.format(LocalDate.of(2020, 2, 16).atStartOfDay(ZoneId.of("GMT+2"))));
  21.     System.out.println(DateTimeFormatter.RFC_1123_DATE_TIME.format(LocalDate.of(2020, 2, 16).atStartOfDay(ZoneId.of("GMT+2"))));
  22.   }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top