WeekFields toString() method in Java with Examples
Last Updated :
29 Jan, 2020
The toString() method of WeekFields class is used to return string representation of this WeekFields object.
Syntax:
public String toString()
Parameters: This method accepts nothing.
Return value: This method returns string representation of this WeekFields.
Below programs illustrate the WeekFields.toString() method:
Program 1:
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
public class GFG {
public static void main(String[] args)
{
WeekFields weekFields
= WeekFields.of(DayOfWeek.MONDAY, 1 );
String toString = weekFields.toString();
System.out.println( "String representation :"
+ toString);
}
}
|
Output:
String representation :WeekFields[MONDAY, 1]
Program 2:
import java.time.temporal.WeekFields;
import java.util.Locale;
public class GFG {
public static void main(String[] args)
{
Locale locale = new Locale( "EN" , "INDIA" );
WeekFields weekFields = WeekFields.of(locale);
String toString = weekFields.toString();
System.out.println( "String representation :"
+ toString);
}
}
|
Output:
String representation :WeekFields[SUNDAY, 1]
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#toString()
Share your thoughts in the comments
Please Login to comment...