Java Instant subtract hours

Description

Java Instant subtract hours

import java.time.Instant;
import java.time.temporal.ChronoUnit;

public class Main {
  public static void main(String[] args) {
    Instant timestamp = Instant.now();
    System.out.println("The current timestamp: " + timestamp);

    Instant yesterday = Instant.now().minus(24, ChronoUnit.HOURS);
    System.out.println("Yesterday: " + yesterday);
  }//from   www .j a v  a 2s .c  o  m
}



PreviousNext

Related