java.time.MonthDay.toString() Method Example



Description

The java.time.MonthDay.toString() method outputs this date as a String, such as --10-15.

Declaration

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

public String toString()

Return Value

a string representation of this date, not null.

Example

The following example shows the usage of java.time.MonthDay.toString() 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.toString());  
   }
}

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

--12-26
Advertisements