Here you can find the source of setDate(int year, int month, int day)
Parameter | Description |
---|---|
year | a parameter |
month | a parameter |
day | a parameter |
public static Calendar setDate(int year, int month, int day)
//package com.java2s; import java.util.Calendar; import java.util.TimeZone; public class Main { /**/*from w w w . j ava 2 s.com*/ * @param year * @param month * @param day * @return */ public static Calendar setDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(TimeZone .getTimeZone("GMT")); calendar.setLenient(false); // Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.getTime(); return calendar; } }