How to get datefields(date,month,year) from datetime in java

Here we will learn how to fetch the date fields from Calendar date. Date fields could be anything from Day, Month, Year.

Here we will use getDisplayName(int field, int style,  Locale locale) method from the Calendar abstract class. This method returns the string representation of the calendar field value in the given style and locale. For complete list of Calendar field visit here.

 

Output of the above code would be

 

 

Leave A Comment

Your email address will not be published. Required fields are marked *