Java Calendar Create getCalendar(int year, int month, int day, int hour, int min, int sec, String timezone)

Here you can find the source of getCalendar(int year, int month, int day, int hour, int min, int sec, String timezone)

Description

get Calendar

License

Open Source License

Declaration

public static Calendar getCalendar(int year, int month, int day, int hour, int min, int sec, String timezone) 

Method Source Code


//package com.java2s;

import java.util.Calendar;
import java.util.TimeZone;

public class Main {
    public static Calendar getCalendar(int year, int month, int day) {
        return getCalendar(year, month, day, 0, 0, 0, "GMT");
    }//ww  w .  ja v  a 2 s . c om

    public static Calendar getCalendar(int year, int month, int day, int hour, int min, int sec) {
        return getCalendar(year, month, day, hour, min, sec, "GMT");
    }

    public static Calendar getCalendar(int year, int month, int day, int hour, int min, int sec, String timezone) {
        return getCalendar(year, month, day, hour, min, sec, TimeZone.getTimeZone(timezone));
    }

    public static Calendar getCalendar(int year, int month, int day, int hour, int min, int sec,
            TimeZone timezone) {
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.DATE, day);
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, min);
        calendar.set(Calendar.SECOND, sec);
        calendar.setTimeZone(timezone);
        return calendar;
    }
}

Related

  1. getCalendar(int d, int m, int y)
  2. getCalendar(int dayOfWeek, int atHour, int atMinute)
  3. getCalendar(int year, int month, int date)
  4. getCalendar(int year, int month, int day)
  5. getCalendar(int year, int month, int day)
  6. getCalendar(int year, int month, int day, int hour, int mins, int secs)
  7. getCalendar(int year, int month, int day, int hours, int minutes, int seconds, TimeZone tz)
  8. getCalendar(int year, int month, int day, TimeZone timeZone)
  9. getCalendar(long millis)