MonthDay now(Clock) method in Java with Examples Last Updated : 12 May, 2020 Comments Improve Suggest changes Like Article Like Report The now(Clock clock) method of the MonthDay class in Java is used to get the current month-day from the specified clock. Syntax: public static MonthDay now(Clock clock) Parameters: This method accepts clock as parameter which represents the clock to use. Return value: This method returns the current month-day. Below programs illustrate the now(Clock clock) method of MonthDay in Java: Program 1: Java // Java program to demonstrate // MonthDay.now(Clock clock) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // apply now(Clock clock) method // of MonthDay class MonthDay result = MonthDay.now( Clock.systemUTC()); // print both month and day System.out.println("MonthDay: " + result); } } Output: MonthDay: --05-09 Program 2: Java // Java program to demonstrate // MonthDay.now(Clock clock) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // apply now(Clock clock) method // of MonthDay class MonthDay result = MonthDay.now( Clock.systemUTC()); // print only month System.out.println("Month: " + result.getMonth()); } } Output: Month: MAY References: https://docs.oracle.com/javase/10/docs/api/java/time/MonthDay.html#now(java.time.Clock) Comment More infoAdvertise with us Next Article MonthDay now() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-MonthDay Practice Tags : Java Similar Reads MonthDay now() method in Java with Examples The now() method of the MonthDay class in Java is used to get the current month-day from the system clock in the default time-zone. Syntax: public static MonthDay now() Parameters: This method does not accept any parameter. Return value: This method returns the current month-day using the system clo 1 min read MonthDay now(ZoneId) method in Java with Examples The now(ZoneId zone) method of the MonthDay class in Java is used to get the current month-day from the system clock in the specified time-zone. Syntax: public static MonthDay now(ZoneId zone) Parameters: This method accepts ZoneId as parameter. Return value: This method returns the current month-da 1 min read MonthDay atYear() method in Java with Examples The atYear() method of MonthDay class in Java combines this month-day with a year to create a LocalDate. Syntax: public LocalDate atYear(int year) Parameter: This method accepts a parameter year which specifies the year to use which is in range [MIN_YEAR, MAX_YEAR] Returns: The function returns the 1 min read MonthDay atYear() method in Java with Examples The atYear() method of MonthDay class in Java combines this month-day with a year to create a LocalDate. Syntax: public LocalDate atYear(int year) Parameter: This method accepts a parameter year which specifies the year to use which is in range [MIN_YEAR, MAX_YEAR] Returns: The function returns the 1 min read MonthDay withMonth() Method in Java with Examples withMonth(int month) method of the MonthDay class used to alter the month-of-year of MonthDay object using month passed as a parameter and after that method returns the copy of altered MonthDay.If the day-of-month is invalid for the specified month, the day will be adjusted to the last valid day-of- 2 min read MonthDay withMonth() Method in Java with Examples withMonth(int month) method of the MonthDay class used to alter the month-of-year of MonthDay object using month passed as a parameter and after that method returns the copy of altered MonthDay.If the day-of-month is invalid for the specified month, the day will be adjusted to the last valid day-of- 2 min read Like