fork download
  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;
  3. import java.util.Locale;
  4. import java.util.TimeZone;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. Date date = new Date();
  9. SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm a zzz", Locale.ENGLISH);
  10.  
  11. sdf.setTimeZone(TimeZone.getTimeZone("America/New_York"));
  12. System.out.println(sdf.format(date));
  13.  
  14. sdf.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
  15. System.out.println(sdf.format(date));
  16. }
  17. }
Success #stdin #stdout 0.22s 55320KB
stdin
Standard input is empty
stdout
05/06/21 08:37 AM EDT
05/06/21 12:37 PM UTC