MDateAndTime { public static DateTimeZone parseTimeZone(String tz) { try { Matcher m = TZ_PATTERN.matcher(tz); if(m.matches()) { int hourSign = "-".equals(m.group(TZ_SIGN_GROUP)) ? -1 : 1; int hour = Integer.parseInt(m.group(TZ_HOUR_GROUP)); int min = Integer.parseInt(m.group(TZ_MINUTE_GROUP)); return DateTimeZone.forOffsetHoursMinutes(hourSign * hour, min); } else { if(tz.indexOf('/') == -1) { tz = tz.toUpperCase(); } return DateTimeZone.forID(tz); } } catch(IllegalArgumentException e) { throw new InvalidDateFormatException("timezone", tz); } }  static String getMonthName(int numericRep, String locale, TExecutionContext context); static long[] fromJodaDateTime(AbstractDateTime date); static MutableDateTime toJodaDateTime(long[] dt, String tz); static MutableDateTime toJodaDateTime(long[] dt, DateTimeZone dtz); static String dateToString(int encodedDate); static int parseAndEncodeDate(String input); static int encodeDate(long millis, String tz); static int encodeDate(long[] dt); static int encodeDate(long y, long m, long d); static long[] decodeDate(long encodedDate); static long[] parseDate(long val); static long[] parseDateTime(long val); static String dateTimeToString(long encodedDateTime); static String dateTimeToString(long[] dt); static StringType parseDateOrTime(String st, long[] dt); static long parseAndEncodeDateTime(String input); static long encodeDateTime(long millis, String tz); static long encodeDateTime(BaseDateTime dt); static long encodeDateTime(long[] dt); static long encodeDateTime(long year, long month, long day, long hour, long min, long sec); static long[] decodeDateTime(long encodedDateTime); static String timeToString(int encodedTime); static String timeToString(long[] dt); static String timeToString(long h, long m, long s); static void timeToDatetime(long[] dt); static int parseTime(String string, TExecutionContext context); static long[] decodeTime(long encodedTime); static int encodeTime(long millis, String tz); static int encodeTime(long[] dt, TExecutionContext context); static int encodeTime(long h, long m, long s, TExecutionContext context); static int parseAndEncodeTimestamp(String input, String tz, TExecutionContext context); static long[] decodeTimestamp(long encodedTimestamp, String tz); static int encodeTimestamp(long[] dt, String tz, TExecutionContext context); static int encodeTimestamp(BaseDateTime dateTime, TExecutionContext context); static int encodeTimestamp(long millis, TExecutionContext context); static boolean isValidTimestamp(BaseDateTime dt); static int getTimestamp(long[] dt, String tz); static String timestampToString(long encodedTimestamp, String tz); static DateTimeZone parseTimeZone(String tz); static boolean isValidDateTime_Zeros(long[] dt); static boolean isValidDateTime(long[] dt, ZeroFlag... flags); static boolean isHrMinSecNegative(long[] dt); static boolean isHrMinSecNegative(long h, long m, long s); static boolean isValidHrMinSec(long[] dt, boolean checkHour, boolean isFromDateTime); static boolean isValidHrMinSec(long h, long m, long s, boolean checkHour, boolean isFromDateTime); static boolean isZeroDayMonth(long[] dt); static boolean isValidDate_Zeros(long[] dt); static boolean isValidDate_NoZeros(long[] dt); static boolean isValidDate(long[] dt, ZeroFlag... flags); static boolean isValidDate(long y, long m, long d, ZeroFlag... flags); static long getLastDay(long[] dt); static long getLastDay(long year, long month); static boolean isValidType(StringType type); static final NoAttrTClass DATE; static final NoAttrTClass DATETIME; static final NoAttrTClass TIME; static final NoAttrTClass YEAR; static final NoAttrTClass TIMESTAMP; static final Map<String, String[]> MONTHS; static final int YEAR_INDEX; static final int MONTH_INDEX; static final int DAY_INDEX; static final int HOUR_INDEX; static final int MIN_INDEX; static final int SEC_INDEX; static final int MAX_INDEX; static final long TIMESTAMP_MIN; static final long TIMESTAMP_MAX; static final long TS_ERROR_VALUE; static final int TIME_MAX; static final int TIME_MIN; }
@Test public void testParseTimeZone() { assertEquals(DateTimeZone.forOffsetHoursMinutes(0, 0), parseTimeZone("0:0")); assertEquals(DateTimeZone.forOffsetHoursMinutes(0, 0), parseTimeZone("00:00")); assertEquals(DateTimeZone.forOffsetHoursMinutes(5, 20), parseTimeZone("+05:20")); assertEquals(DateTimeZone.forOffsetHoursMinutes(-5, 45), parseTimeZone("-05:45")); assertEquals(DateTimeZone.forOffsetHoursMinutes(0, 0), parseTimeZone("UTC")); assertEquals(DateTimeZone.forID("MET"), parseTimeZone("met")); assertEquals(DateTimeZone.forID("MET"), parseTimeZone("MET")); assertEquals(DateTimeZone.forID("America/Los_Angeles"), parseTimeZone("America/Los_Angeles")); try { parseTimeZone("asdf"); } catch(InvalidDateFormatException e) { } try { parseTimeZone("00x:00y"); } catch(InvalidDateFormatException e) { } }