java.time.Year.toString() Method Example



Description

The pjava.time.Year.toString() method gets a string representation of this Year.

Declaration

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

public String toString()

Return Value

a string representation of this year, not null.

Example

The following example shows the usage of java.time.Year.toString() method.

package com.tutorialspoint;

import java.time.Year;

public class YearDemo {
   public static void main(String[] args) {

      Year date = Year.parse("2017");
      System.out.println(date.toString());  
   }
}

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

2017
Advertisements