fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.sql.Timestamp;
  8. import java.time.* ;
  9. import java.time.format.* ;
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. // Converting from `Timestamp`
  17. Timestamp myTimestamp = Timestamp.from( Instant.now() );
  18. System.out.println(
  19. myTimestamp
  20. .toInstant()
  21. .atZone(
  22. ZoneId.of( "Asia/Tokyo" )
  23. )
  24. .format(
  25. DateTimeFormatter
  26. .ofLocalizedDateTime(
  27. FormatStyle.FULL
  28. )
  29. .withLocale(
  30. Locale.FRANCE
  31. )
  32. )
  33. );
  34.  
  35. // Current moment
  36. System.out.println(
  37.  
  38. ZonedDateTime
  39. .now(
  40. ZoneId.of( "Asia/Tokyo" )
  41. )
  42. .format(
  43. DateTimeFormatter
  44. .ofLocalizedDateTime(
  45. FormatStyle.FULL
  46. )
  47. .withLocale(
  48. Locale.FRANCE
  49. )
  50. )
  51.  
  52. );
  53. }
  54. }
Success #stdin #stdout 0.27s 57412KB
stdin
Standard input is empty
stdout
mardi 28 décembre 2021 à 05:49:06 heure normale du Japon
mardi 28 décembre 2021 à 05:49:06 heure normale du Japon