Posted In: Date, Java Core

Convert java.util.Date to java.time.LocalDate, LocalDateTime

Date date1 = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”) .parse(“2017-08-13 12:10:30”); LocalDate localdate = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); LocalDateTime localdatetime = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();

Read More

by , on August 24th, 2017

Posted In: Date, Java Core

Comparing two Dates without the time portion

Techniques used 1. JODA Time DateTimeComparator 2. Apache Commons DateUtils 3. JDK 8 LocalDate 4. Below JDK 8 DateFormat  

Read More

by , on August 24th, 2017

Posted In: Date, Java Core

Calculate number of days between two Java date instances

Calculate difference between two Java date instances Techniques used 1. Using java.util.Date Before JDK 8 2. Using java.time.LocalDate JDK 8 3. Using JODA time org.joda.time.Days 4. Using JODA time org.joda.time.Interval

Read More

by , on August 23rd, 2017

Posted In: Date, Java Core

Parsing ISO 8601-compliant String to java.util.Date

Best way to parse an XML dateTime in Java Techniques used 1. JODA Time 2. JAXB  

Read More

by , on August 23rd, 2017

Posted In: Date, Java Core

Convert date string to one format to another

This function will convert date string format to another format. Test

Read More

Tags:

by , on April 2nd, 2017

  • Categories