Java TimeZone Get getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds, String timezone)

Here you can find the source of getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds, String timezone)

Description

Get calendar date.

License

Apache License

Declaration

public static Date getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds,
        String timezone) throws Exception 

Method Source Code


//package com.java2s;
/*/*from   w  w  w  .j  av  a 2s .  c  o  m*/
 * StatusFeedParser.java
 *
 * Copyright (C) 2005-2008 Tommi Laukkanen
 * http://www.substanceofcode.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

public class Main {
    private static final String[] MONTH = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
            "Nov", "Dec" };

    /**
     * Get calendar date. *
     */
    public static Date getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds,
            String timezone) throws Exception {
        // Create calendar object from date values
        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("GMT" + timezone));
        cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.HOUR_OF_DAY, hours);
        cal.set(Calendar.MINUTE, minutes);
        cal.set(Calendar.SECOND, seconds);

        return cal.getTime();
    }
}

Related

  1. getAdjustedDateTime(Date dt, TimeZone tz)
  2. getAllTimezonesSorted()
  3. getAsTimeZone(Map params, String propName)
  4. getAvailableTimezones()
  5. getCalendarForTimeZone(final String timeZone)
  6. getCalendarInstance(TimeZone timeZone, Locale locale)
  7. getConvertDateString(Date date, TimeZone tz, String fmt)
  8. getCurrentCalendarInTimeZone(final TimeZone timeZone)