Java Date Time - LocalDateTime minusHours(long hours) example








LocalDateTime minusHours(long hours) returns a copy of this LocalDateTime with the specified period in hours subtracted.

Syntax

minusHours has the following syntax.

public LocalDateTime minusHours(long hours)

Example

The following example shows how to use minusHours.

import java.time.LocalDateTime;
/*from   w w w . j a  v a 2s.c  o  m*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    
    LocalDateTime t = a.minusHours(100);
    
    System.out.println(t);
  }
}

The code above generates the following result.