fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. Date source = new Date();
  15. printDate(source);
  16. ZonedDateTime zdt = source.toInstant().atZone(ZoneOffset.ofHours(5));
  17. System.out.println(zdt.toString());
  18. printDate(Date.from(zdt.toInstant()));
  19. }
  20.  
  21. private static void printDate(Date d) {
  22. System.out.println(d.toString());
  23. }
  24. }
Success #stdin #stdout 0.1s 36208KB
stdin
Standard input is empty
stdout
Thu Apr 09 17:24:08 GMT 2020
2020-04-09T22:24:08.726+05:00
Thu Apr 09 17:24:08 GMT 2020