Here you can find the source of getTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis)
private static long getTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { private static int zoneOffset; private static Calendar cachedCalendar; private static long getTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis) { Calendar c;/*from w w w. ja va2 s . co m*/ if (tz == null) { c = getCalendar(); } else { c = Calendar.getInstance(tz); } synchronized (c) { c.clear(); c.setLenient(lenient); setCalendarFields(c, year, month, day, hour, minute, second, millis); return c.getTime().getTime(); } } private static Calendar getCalendar() { if (cachedCalendar == null) { cachedCalendar = Calendar.getInstance(); zoneOffset = cachedCalendar.get(Calendar.ZONE_OFFSET); } return cachedCalendar; } private static void setCalendarFields(Calendar cal, int year, int month, int day, int hour, int minute, int second, int millis) { if (year <= 0) { cal.set(Calendar.ERA, GregorianCalendar.BC); cal.set(Calendar.YEAR, 1 - year); } else { cal.set(Calendar.ERA, GregorianCalendar.AD); cal.set(Calendar.YEAR, year); } // january is 0 cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.set(Calendar.SECOND, second); cal.set(Calendar.MILLISECOND, millis); } }