Overview. In this tutorial you will learn how to refactor your code in order to leverage the new Date Time API introduced in Java 8. 2. New API at a Glance. Working with dates in Java used to be hard. The old date library provided by JDK included only three classes: java.util.Date, java.util.Calendar and java.util.Timezone. 5 Answers. Sorted by: 5. You should use a Calendar object. Much easier to manage, and if you need to get to a date there are methods for that. Calendar cal = Calendar.getInstance (); //Set to whatever date you want as default cal.set (Calendar.YEAR, *year you want*); Share. Improve this answer. If you have the month and the year and you just need the first day of the month I would do something like this: DayOfWeek firstDay = LocalDate.of(year, month, 1).getDayOfWeek(); Basically, you build a date where the dayOfMonth param is 1. Based on your solution for the first day of a month assuming yearMonth is a LocalDate this should work: The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. Use DATE or DAY_OF_MONTH both are same. Here is the difference : DATE or DAY_OF_MONTH : Get and Set indicating the day of the month DAY_OF_WEEK : get and set indicating the week number within the current month DAY_OF_YEAR : get and set indicating the day number within the current ye But since sdf.format is returning to a string,after formating 1 time i cant format it again to my desired Monthname day,Year format before displaying to user. i mean if sdf.format(firstdate) returns "01/01/2000" string,i would like to convert this to January 1,2000 and then display it to user. Sorted by: 22. The same way you do for String and Int , you just place different types inside: Date [] dates = { new Date (), new Date () }; Declared an array of size two with two dates. You can also initialize with null values: Date [] dates = new Date [2]; Or add more significant values: Date [] dates = { getDateFromString ("25/11/2009 Date(year, month, day) is deprecated since JDK version 1.1 ! See the GregorianCalendar JavaDoc: Constructs a GregorianCalendar with the given date set in the default time zone with the default locale. The standard mental model for a date is based on three concepts - year, month and day. These map onto the YEAR, MONTH_OF_YEAR and DAY_OF_MONTH fields. Note that there is no reference to eras. The full model for a date requires four concepts - era, year, month and day. These map onto the ERA, YEAR_OF_ERA, MONTH_OF_YEAR and DAY_OF_MONTH fields. We are attempting to write a single DateTimeFormatter that helps us validate an ISO 8601 that allows our end user's to enter just a year, a year and a month, or a year, month, and day. We also want to validate the entered date actually exists. In the following code there are two examples of dates and date validation acting funky. 0Ryu1L.