Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java days between two localdate

LocalDate dateBefore;
LocalDate dateAfter;
long daysBetween = DAYS.between(dateBefore, dateAfter);
Comment

difference between two LocalDateTime java

long minutes = ChronoUnit.MINUTES.between(fromDate, toDate);
long hours = ChronoUnit.HOURS.between(fromDate, toDate);
Comment

difference between two LocalDateTime java

LocalDateTime fromDateTime = LocalDateTime.of(1984, 12, 16, 7, 45, 55);
LocalDateTime toDateTime = LocalDateTime.of(2014, 9, 10, 6, 40, 45);

LocalDateTime tempDateTime = LocalDateTime.from( fromDateTime );

long years = tempDateTime.until( toDateTime, ChronoUnit.YEARS );
tempDateTime = tempDateTime.plusYears( years );

long months = tempDateTime.until( toDateTime, ChronoUnit.MONTHS );
tempDateTime = tempDateTime.plusMonths( months );

long days = tempDateTime.until( toDateTime, ChronoUnit.DAYS );
tempDateTime = tempDateTime.plusDays( days );


long hours = tempDateTime.until( toDateTime, ChronoUnit.HOURS );
tempDateTime = tempDateTime.plusHours( hours );

long minutes = tempDateTime.until( toDateTime, ChronoUnit.MINUTES );
tempDateTime = tempDateTime.plusMinutes( minutes );

long seconds = tempDateTime.until( toDateTime, ChronoUnit.SECONDS );

System.out.println( years + " years " + 
        months + " months " + 
        days + " days " +
        hours + " hours " +
        minutes + " minutes " +
        seconds + " seconds.");

//prints: 29 years 8 months 24 days 22 hours 54 minutes 50 seconds.
Comment

PREVIOUS NEXT
Code Example
Java :: binary to decimal in java program 
Java :: android studio download 
Java :: classcastexception in java 
Java :: how to use sql file in java 
Java :: java files 
Java :: armstrong number in java 
Java :: java string to integer 
Java :: how to change actionbar color in android programmatically 
Java :: encapsulation in oop 
Java :: java.lang.object[4] 
Java :: string length in android studio java 
Java :: java 2d array length 
Java :: java get month 
Java :: generic list java 
Java :: Could not determine java version from 
Java :: render problem in android studio 
Java :: java method reference 
Java :: convert a int to string in java 
Java :: HttpContext.GetOwinContext().Authentication.SignOut 
Java :: if driver.find_element_by_xpath selnium java is displayed 
Java :: java set textview style 
Java :: check first character of string is number java 
Java :: How to efficiently reverse a singly linked list, in Java? 
Java :: richest customer wealth leetcode 
Java :: export JAVA_HOME=` mac 
Java :: How to check if a string is in alphabetical order in java 
Java :: java_remove last char 
Java :: how to set context path in spring boot 
Java :: first line of java code 
Java :: java system.out.println not working 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =