Java Date Set setDate(int year, int month, int day)

Here you can find the source of setDate(int year, int month, int day)

Description

set Date

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter
day a parameter

Declaration

public static Calendar setDate(int year, int month, int day) 

Method Source Code

//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;
    }
}

Related

  1. resetTime(Date date)
  2. resetTime(Date dt)
  3. setDate(Date date, int year, int month, int day)
  4. setDate(Date dateToSet, int hours, int minutes, int seconds, int milisec, TimeZone zone, Locale locale)
  5. SetDate(int year, int month, int day)
  6. setDateHourMinute(Date dateParam, String hourMinute, String format)
  7. setDateSecond(Date dateParam, int second)
  8. setDateToDayStart(final Date date)
  9. setDateToStartOfDay(Date date)