java calendar set date

Solutions on MaxInterview for java calendar set date by the best coders in the world

showing results for - "java calendar set date"
Julia
03 Jan 2020
1package com.tutorialspoint;
2
3import java.util.Calendar;
4
5public class CalendarDemo {
6   public static void main(String[] args) {
7
8      // create a calendar
9      Calendar cal = Calendar.getInstance();
10
11      // print current time
12      System.out.println("Current year is :" + cal.getTime());
13
14      // set the year,month and day to something else
15      cal.set(1995, 5, 25);
16
17      // print the result
18      System.out.println("Altered year is :" + cal.getTime()); 
19   }
20}