fork download
  1. import java.time.ZoneId;
  2. import java.time.ZonedDateTime;
  3. import java.time.format.DateTimeFormatter;
  4. import java.time.format.DateTimeFormatterBuilder;
  5. import java.util.Locale;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Kolkata"));
  10.  
  11. DateTimeFormatter dtf1 =
  12. new DateTimeFormatterBuilder()
  13. .appendPattern("MMMM dd, uuuu 'at' h:mm:ss a 'UTC'")
  14. .appendOffset("+H:mm", "Z")
  15. .toFormatter(Locale.ENGLISH);
  16.  
  17. System.out.println(now.format(dtf1));
  18.  
  19. DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss OOOO uuuu", Locale.ENGLISH);
  20. System.out.println(now.format(dtf2));
  21. }
  22. }
Success #stdin #stdout 0.14s 52836KB
stdin
Standard input is empty
stdout
September 15, 2021 at 10:21:55 PM UTC+5:30
Wed Sep 15, 22:21:55 GMT+05:30 2021