List of usage examples for java.util Calendar setTimeZone
public void setTimeZone(TimeZone value)
From source file:Main.java
private static GregorianCalendar gmtStringToGregorianCalendar(String stringTypeDate) throws DatatypeConfigurationException { String yyyy = stringTypeDate.substring(0, 4); String mm = stringTypeDate.substring(5, 7); String dd = stringTypeDate.substring(8, 10); String hh = "00"; String mi = "00"; String ss = "00"; String ms = "00"; String tz = null;/*www. j a va 2s. c om*/ if (stringTypeDate.length() > 23) { hh = stringTypeDate.substring(11, 13); mi = stringTypeDate.substring(14, 16); ss = stringTypeDate.substring(17, 19); ms = stringTypeDate.substring(20, 23); tz = stringTypeDate.substring(23); } else { tz = stringTypeDate.substring(10); //tz = "+09:00"; } if (tz.equals("Z")) { tz = "UTC"; } else { tz = "GMT" + tz; } int iyyyy = Integer.parseInt(yyyy); int imm = Integer.parseInt(mm) - 1; int idd = Integer.parseInt(dd); int ihh = Integer.parseInt(hh); int imi = Integer.parseInt(mi); int iss = Integer.parseInt(ss); int ims = Integer.parseInt(ms); Calendar c = Calendar.getInstance(); c.setTimeZone(TimeZone.getTimeZone(tz)); c.set(iyyyy, imm, idd, ihh, imi, iss); c.set(Calendar.MILLISECOND, ims); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(c.getTime()); cal.setTimeZone(TimeZone.getTimeZone("ROK")); return cal; }
From source file:Main.java
public static long getDateMills(int year, int month, int day) { //Date d = new Date(year, month, day); // 1960 4 22// ww w. j av a 2s . co m Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.set(year, month, day); TimeZone tz = TimeZone.getDefault(); calendar.setTimeZone(tz); return calendar.getTimeInMillis(); }
From source file:DateUtil.java
public static String formatHTTPDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("GMT+0")); cal.setTime(date);//from w w w . j a v a2 s. co m return DAY_OF_WEEK[cal.get(Calendar.DAY_OF_WEEK) - 1] + ", " + cal.get(Calendar.DAY_OF_MONTH) + " " + MONTH[cal.get(Calendar.MONTH)] + " " + cal.get(Calendar.YEAR) + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND) + " GMT"; //Tue%2C+27+Mar+2007+22%3A55%3A48+GMT }
From source file:DateUtil.java
/** 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(); }
From source file:ca.rmen.android.poetassistant.wotd.Wotd.java
static Calendar getTodayUTC() { Calendar now = Calendar.getInstance(); now.setTimeZone(TimeZone.getTimeZone("UTC")); now.set(Calendar.HOUR_OF_DAY, 0); now.set(Calendar.MINUTE, 0);/* w w w.j a v a 2s .c o m*/ now.set(Calendar.SECOND, 0); now.set(Calendar.MILLISECOND, 0); return now; }
From source file:com.vangent.hieos.xutil.hl7.date.Hl7Date.java
/** * * @param date/*from ww w .java 2 s . co m*/ * @return */ static public String toDTM_UTCTimeZone(Date date) { Calendar c = new GregorianCalendar(); c.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTime(date); return Hl7Date.formatDTM(c); }
From source file:org.commonjava.indy.model.util.HttpUtils.java
public static String formatDateHeader(final Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);// w w w .j ava 2 s. com cal.setTimeZone(TimeZone.getTimeZone("GMT")); return new SimpleDateFormat(DATE_HEADER_FMT).format(date) + GMT_SUFFIX; }
From source file:es.tekniker.framework.ktek.util.Utils.java
public static Calendar getCalendarGMT() { Calendar c = Calendar.getInstance(); c.setTimeZone(TimeZone.getTimeZone("GMT")); return c;//from w w w . ja va 2s. c o m }
From source file:org.commonjava.indy.model.util.HttpUtils.java
public static String formatDateHeader(final long date) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date(date)); cal.setTimeZone(TimeZone.getTimeZone("GMT")); return new SimpleDateFormat(DATE_HEADER_FMT).format(cal.getTime()) + GMT_SUFFIX; }
From source file:org.openmeetings.utils.math.TimezoneUtil.java
public static long _getOffset(TimeZone timezone) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(timezone); return cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); }