fork(2) download
  1. import java.time.Instant;
  2. import java.time.LocalDate;
  3. import java.time.ZoneId;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. long timestampDate = 1623307684L;
  8. Instant instant = Instant.ofEpochSecond(timestampDate);
  9.  
  10. // Replace JVM's timezone, ZoneId.systemDefault() with the applicable timezone
  11. // e.g. ZoneId.of("Etc/UTC")
  12. LocalDate date = instant.atZone(ZoneId.systemDefault()).toLocalDate();
  13. LocalDate today = LocalDate.now(ZoneId.systemDefault());
  14. if (date.isBefore(today)) {
  15. System.out.println("The given timestamp is for a date in the past.");
  16. // ...
  17. }
  18.  
  19. if (date.equals(today.minusDays(1))) {
  20. System.out.println("Yesterday");
  21. }
  22. }
  23. }
  24.  
Success #stdin #stdout 0.07s 48132KB
stdin
Standard input is empty
stdout
Standard output is empty