Methods of Java MonthDay Class. It is used to combine this month-day with a year to create a LocalDate. It is used to format this month-day using the specified formatter. It is used to get the value of the specified field from this month-day as an int. It is used to check if the year is valid for this month-day. public final class Period extends Object implements ChronoPeriod, Serializable. A date-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days'. This class models a quantity or amount of time in terms of years, months and days. See Duration for the time-based equivalent to this class. To check which Saturday or Sunday it is, you simply have to use (dayOfYearInput - dayOfYearFirst) / 7 + 1 which will give you an ordinal of which Saturday / Sunday it is. The same approach can be used with java.util.Calendar#get (Calendar.DAY_OF_YEAR) btw - but joda time is particularly useful if you want to persist to a database for example. I am using java.time.Year, one of a number of date and time classes introduced in Java 8 (and also backported to Java 6 and 7). This is just one little example out of very many where the new classes are more convenient and lead to clearer code than the old classes Calendar and SimpleDateFormat . LocalDate.now() // Capture the date-only value current in the JVM’s current default time zone. .getYear() // Extract the year number from that date. 2018. java.time. Both the java.util.Date and java.util.Calendar classes are legacy, now supplanted by the java.time framework built into Java 8 and later. A time zone is crucial in determining a 0. I am trying to create a method which converts DAY, MONTH, YEAR to Date object in Java. I have. String DAY = "31" String YEAR = "2012" String MONTH = "11". I need a configurable Format as output. String format = "MM/dd/yyy"; I will always get DAY string from "01" to "31" only. I will always get YEAR string from "1000" to "9999" only. Enter a day of the year or 0 to quit: 10 Jan 10 Enter a day of the year or 0 to quit: 200 Jul 19 Enter a day of the year or 0 to quit: 0 Bye! Share Follow If one wants to get the week number based on 7 days no matter when the week starts and how many days the first partial week of the year has, ChronoField.ALIGNED_WEEK_OF_YEAR might be helpful. For example, the 1st of January 2016 based on the ISO-8601 definition (where a week starts on Monday and the first week has a minimum of 4 days) falls I am working on a piece of work where I need to get year, month, day from a String in Java. The string is like that: 20170119T163048. Where 2017 is year, 01 is month, 19 is day, 16:30:48 is time. public void convertStringToDate (String string) { String dateInString = ""; SimpleDateFormat formatter = new SimpleDateFormat (); Date date Java program to extract the day, month and year from a date in Java 8. LocalDate today = LocalDate.now (); //23-Feb-022 int day = today.getDayOfMonth (); //23 int month = today.getMonthValue (); //2 int year = today.getYear (); //2022. We can invoke these same methods with LocalDateTime and other classes as well. 1yemr.