Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java localdate subtract two dates

@Test
public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() {
    LocalDate now = LocalDate.now();
    LocalDate sixDaysBehind = now.minusDays(6);
 
    Period period = Period.between(now, sixDaysBehind);
    int diff = period.getDays();
 
    assertEquals(diff, 6);
}
Comment

PREVIOUS NEXT
Code Example
Java :: list java 
Java :: how to name loops in java 
Java :: how to strip spaces in java using split with other delimiters 
Java :: concurrenthashmap in java 
Java :: android studio remove button onclick 
Java :: how to replace an element in array in java 
Java :: float.compare java 
Java :: convert class to java command line 
Java :: array find max in java 
Java :: mockito method called 
Java :: como crear un array list en java 
Java :: how to convert string to int in java 
Java :: android dialog modal 
Java :: remove all element in a list java 
Java :: if checkbox checked java 
Java :: queue.isempty java 
Java :: java string equal 
Java :: Infinite While Loop Java Example 
Java :: align button to the left in JPanel 
Java :: practical1_answer 
Java :: pass a list of string as PathVariable to api spring boot 
Java :: What is the function of an IntentFilter? 
Java :: mvn spring boot ends when closing vm 
Java :: spring boot put invalid cors request 
Java :: Sending String from one activity to another 
Java :: split string into array java 
Java :: create an empty array in java 
Java :: intellij set target bytecode version 
Java :: current port used by the Java application 
Java :: java noverify 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =