Calendar toString() Method in Java with Examples Last Updated : 13 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The toString() method in Calendar class is used to get the string representation of the Calendar object. This method in Calendar Class is just for debug process and not to be used as an operation. Syntax: public String toString() Parameters: The method does not take any parameters. Return Value: The method returns the String representation of the Calendar object. It can return an empty object but not null. Below programs illustrate the working of toString() Method of Calendar class: Example 1: Java // Java Code to illustrate toString() Method import java.util.*; public class CalendarClassDemo { public static void main(String args[]) { // Creating a calendar object Calendar calndr1 = Calendar.getInstance(); // Returning the string representation System.out.println("The string form: " + calndr1.getTime() .toString()); } } Output: The string form: Wed Feb 13 09:46:36 UTC 2019 Example 2: Java // Java Code to illustrate toString() Method import java.util.*; public class CalendarClassDemo { public static void main(String args[]) { // Creating a calendar object Calendar calndr1 = new GregorianCalendar(2018, 12, 2); // Returning the string representation System.out.println("The string form: " + calndr1.getTime() .toString()); } } Output: The string form: Wed Jan 02 00:00:00 UTC 2019 Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#toString() Comment More infoAdvertise with us Next Article Calendar toString() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-Calendar +1 More Practice Tags : JavaMisc Similar Reads Calendar set() Method in Java with Examples The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field. Syntax: public void set(int calndr_field, int new_val) Parameters: The method takes two parameters: calndr_field: This is 2 min read Date toString() method in Java with Examples The toString() method of Java Date class converts this date object into a String in form "dow mon dd hh:mm:ss zzz yyy". This method overrides toString in class object. Syntax: public String toString() Parameters: The function does not accept any parameter. Return Value: It method returns a string re 2 min read Calendar setTime() Method in Java with Examples The setTime(Date dt) method in Calendar class is used to set Calendars time represented by this Calendar's time value, with the given or passed date as a parameter. Syntax: public final void setTime(Date dt)) Parameters: The method takes one parameter dt of Date type and refers to the given date tha 2 min read Calendar setLenient() Method in Java with Examples The setLenient(boolean leniency) method in Calendar class is used to specify whether the interpretation of the date and time is to be lenient or not. Syntax: public void setLenient(boolean leniency) Parameters: The method takes one parameter leniency of the boolean type that refers to the mode of th 2 min read ChronoLocalDate toString() method in Java with Examples The toString() method of a ChronoLocalDate interface is used to get this date as a String, such as 2019-01-01.The output will be in the ISO-8601 format uuuu-MM-dd. Syntax: public String toString() Parameters: This method does not accepts any parameters. Return value: This method returns String which 1 min read Duration toString() method in Java with Examples The toString() method of Duration Class in java.time package is used to get the String value of this duration. This String is in the ISO-8601 format. Syntax: public String toString() Parameters: This method do not accepts any parameter. Return Value: This method returns a String value which is the S 1 min read Calendar get() method in Java with Examples The get(int field_value) method of Calendar class is used to return the value of the given calendar field in the parameter. Syntax: public int get(int field) Parameters: The method takes one parameter field_value of integer type and refers to the calendar whose value is needed to be returned. Return 2 min read Calendar add() Method in Java with Examples The add() method of Calendar class present inside is used to add or subtract from the given calendar field(int field), a specific amount of time(int amt), based on the calendar's rules. Syntax: public abstract void add(int field, int amt) Parameters: The method takes two parameters: The field of the 3 min read ChronoPeriod toString() method in Java with Examples The toString() method of ChronoPeriod interface in Java is used to return a String representation of this ChronoPeriod. Syntax: ChronoPeriod toString() Parameters: This method does not accepts any parameter. Return Value: This method returns String representation of this Below program illustrates th 1 min read Year toString() method in Java with Examples The toString() method of Year class in Java is used to return the string representation of this Year object. Syntax: public String toString() Parameter: This method does not accepts any parameter. Return Value: It returns the string representation of this Year object. Below programs illustrate the t 1 min read Like