java.time.MonthDay.now() Method Example



Description

The java.time.MonthDay.now() method obtains the current month-day from the system clock in the default time-zone.

Declaration

Following is the declaration for java.time.MonthDay.now() method.

public static MonthDay now()

Return Value

the current month-day using the system clock and default time-zone, not null.

Example

The following example shows the usage of java.time.MonthDay.now() method.

package com.tutorialspoint;

import java.time.MonthDay;

public class MonthDayDemo {
   public static void main(String[] args) {
 
      MonthDay date = MonthDay.now();
      System.out.println(date);  
   }
}

Let us compile and run the above program, this will produce the following result −

--12-26
Advertisements