Java Instant subtract days

Description

Java Instant subtract days

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);

    // Now minus three days
    Instant minusThree = timestamp.minus(3, ChronoUnit.DAYS);
    System.out.println("Now minus three days:" + minusThree);
  }//from   w  w w . ja  va 2  s .c om
}



PreviousNext

Related