+ }
+ return false;
+ }
+ return false;
+ }
+
+
+ /**
+ * Try to parse the given string with the given date format
+ * @param inString String to parse
+ * @param inDateFormat Date format to use
+ * @return true if successful
+ */
+ private boolean parseString(String inString, DateFormat inDateFormat)
+ {
+ inDateFormat.setLenient(false);
+ ParsePosition pPos = new ParsePosition(0);
+ Date date = inDateFormat.parse(inString, pPos);
+ if (date != null && inString.length() == pPos.getIndex()) // require use of _all_ the string, not just the beginning
+ {
+ CALENDAR.setTime(date);
+ _milliseconds = CALENDAR.getTimeInMillis();
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Constructor giving each field value individually
+ * @param inYear year
+ * @param inMonth month, beginning with 1
+ * @param inDay day of month, beginning with 1
+ * @param inHour hour of day, 0-24
+ * @param inMinute minute
+ * @param inSecond seconds
+ */
+ public Timestamp(int inYear, int inMonth, int inDay, int inHour, int inMinute, int inSecond)
+ {
+ _milliseconds = getMilliseconds(inYear, inMonth, inDay, inHour, inMinute, inSecond, null, null);
+ _valid = true;
+ }
+
+
+ /**
+ * Constructor giving millis
+ * @param inMillis milliseconds since 1970
+ */
+ public Timestamp(long inMillis)
+ {
+ _milliseconds = inMillis;
+ _valid = true;
+ }
+
+
+ /**
+ * Convert the given timestamp parameters into a number of milliseconds
+ * @param inYear year
+ * @param inMonth month, beginning with 1
+ * @param inDay day of month, beginning with 1
+ * @param inHour hour of day, 0-24
+ * @param inMinute minute
+ * @param inSecond seconds
+ * @param inFraction fractions of a second
+ * @param inTimezone timezone, if any
+ * @return number of milliseconds
+ */
+ private static long getMilliseconds(int inYear, int inMonth, int inDay,
+ int inHour, int inMinute, int inSecond, String inFraction, String inTimezone)
+ {
+ Calendar cal = Calendar.getInstance();
+ // Timezone, if any
+ if (inTimezone == null || inTimezone.equals("") || inTimezone.equals("Z")) {
+ // No timezone, use zulu
+ cal.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+ else {
+ // Timezone specified, pass to calendar
+ cal.setTimeZone(TimeZone.getTimeZone("GMT" + inTimezone));
+ }
+ cal.set(Calendar.YEAR, inYear);
+ cal.set(Calendar.MONTH, inMonth - 1);
+ cal.set(Calendar.DAY_OF_MONTH, inDay);
+ cal.set(Calendar.HOUR_OF_DAY, inHour);
+ cal.set(Calendar.MINUTE, inMinute);
+ cal.set(Calendar.SECOND, inSecond);
+ int millis = 0;
+ if (inFraction != null)
+ {
+ try {
+ int frac = Integer.parseInt(inFraction);
+ final int fracLen = inFraction.length();
+ switch (fracLen) {
+ case 1: millis = frac * 100; break;
+ case 2: millis = frac * 10; break;
+ case 3: millis = frac; break;