Answers for "java calendar set date"

1

java calendar set date

package com.tutorialspoint;

import java.util.Calendar;

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

      // create a calendar
      Calendar cal = Calendar.getInstance();

      // print current time
      System.out.println("Current year is :" + cal.getTime());

      // set the year,month and day to something else
      cal.set(1995, 5, 25);

      // print the result
      System.out.println("Altered year is :" + cal.getTime()); 
   }
}
Posted by: Guest on July-18-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language