Here you can find the source of getCalendar(String gdate)
Parameter | Description |
---|---|
gdate | a parameter |
public static Calendar getCalendar(String gdate)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.TimeZone; public class Main { /**//from w w w .j a v a 2 s . co m * Get a Calendar for this gdate, or null in case of failure * @param gdate * @return */ public static Calendar getCalendar(String gdate) { return getCalendar(gdate, null); } /** * Get a Calendar for this gdate, or ndef in case of failure * @param gdate * @param def * @return */ public static Calendar getCalendar(String gdate, Calendar def) { if ((gdate != null) && (gdate.length() < 14)) gdate = gdate + "00000000000000"; if ((gdate == null) || (gdate.length() < 14)) { return def; } Calendar date = CalendargetInstance(); try { date.set(Integer.parseInt(gdate.substring(0, 4)), Integer.parseInt(gdate.substring(4, 6)) - 1, Integer.parseInt(gdate.substring(6, 8)), Integer.parseInt(gdate.substring(8, 10)), Integer.parseInt(gdate.substring(10, 12)), Integer.parseInt(gdate.substring(12, 14))); date.set(Calendar.MILLISECOND, Integer.parseInt(gdate.substring(15, 18))); } catch (Exception e) { return def; } //System.out.println("getCalendar "+gdate+" into "+date); return date; } /** * Return now at UTC * @return */ public static Calendar CalendargetInstance() { return Calendar.getInstance(TimeZone.getTimeZone("UTC")); } }