fork download
  1. import java.time.Instant;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5. Instant instant = Instant.now();
  6.  
  7. // You can pass the following string to JavaScript
  8. String strInstant = instant.toString();
  9. System.out.println(strInstant);
  10.  
  11. // If the number of milliseconds from epoch is required
  12. long millis = instant.toEpochMilli();
  13. System.out.println(millis);
  14. }
  15. }
Success #stdin #stdout 0.11s 48800KB
stdin
Standard input is empty
stdout
2022-12-31T09:34:12.358827Z
1672479252380