Java Time in GMT getGMTCalendarAtTime(String sTime)

Here you can find the source of getGMTCalendarAtTime(String sTime)

Description

Gets the calendar at given time at GMT

License

Open Source License

Declaration

public static Calendar getGMTCalendarAtTime(String sTime) throws ParseException 

Method Source Code


//package com.java2s;
/* Penny Post - A postage system for email
 * Copyright (c) 2006-2007  Gregory Rubin <grrubin@gmail.com> 
 * http://www.nettgryppa.com //from ww w .  j  a va  2s .  c o  m
*  Copyright (C) 2007  Aliasgar Lokhandwala <d7@freepgs.com> 
 * http://pennypost.sourceforge.net/
 * 
 * CashUtils.java: Provides common helper methods
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
    
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
    
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class Main {
    /**
     * Date format string
     */
    public static final String m_sDtFormat = "yyMMdd";

    /**
     * Gets the calendar at given time at GMT
     * @author Ali
     */
    public static Calendar getGMTCalendarAtTime(String sTime) throws ParseException {
        SimpleDateFormat dtFormat = new SimpleDateFormat(m_sDtFormat);
        Calendar newDate = getGMTCalendar();
        newDate.setTime(dtFormat.parse(sTime));
        return newDate;
    }

    /**
     * Gets the calendar at current time at GMT
     * @author Ali
     */
    public static Calendar getGMTCalendar() {
        return Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    }
}

Related

  1. getGMT(Date date)
  2. getGMT8Time()
  3. getGMTByDisplay(String tm)
  4. getGMTDate()
  5. getGMTDateFormat(String format)
  6. getGMTDateFormat(String strFormat)
  7. getGMTDateString(Date date)