fork download
  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;
  3. import java.util.TimeZone;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Date now = new Date();
  8.  
  9.  
  10. // For the JVM's timezone
  11. sdf.setTimeZone(TimeZone.getDefault());
  12. System.out.println(sdf.format(now));
  13.  
  14. // For the timezone, UTC
  15. sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
  16. System.out.println(sdf.format(now));
  17.  
  18. // For the timezone, Australia/Brisbane
  19. sdf.setTimeZone(TimeZone.getTimeZone("Australia/Brisbane"));
  20. System.out.println(sdf.format(now));
  21.  
  22. System.out.println();
  23. }
  24. }
Success #stdin #stdout 0.18s 51296KB
stdin
Standard input is empty
stdout
289
289
290