Sunday 15 February 2015

Java8 DateTime: Conversion and Formatter

We have seen in a recent post how to deal with the new API DateTime in Java8. 
In this post we will explore the formatting options and how to do the conversion from LocalDate (Java8) to Date (legacy API) and viceversa

Example1- How to convert from legacy to new API 
The following examples are the conversion from Date and Calendar to LocalDate.

Example2- How to convert from new API to legacy
Conversion from LocalDate to Date.


Example3- Use of formatter
How to convert from LocalDate to String and viceversa.
It is supported by class Formatter (equivalent of SimpleDateFormat for the legacy API).

No comments:

Post a Comment