/** * Constructor */ public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision, TimeZone theTimeZone) { this(theDate, thePrecision); setTimeZone(theTimeZone); }
private BaseDateTimeDt setTimeZone(String theWholeValue, String theValue) { if (isBlank(theValue)) { throwBadDateFormat(theWholeValue); } else if (theValue.charAt(0) == 'Z') { clearTimeZone(); setTimeZoneZulu(true); } else if (theValue.length() != 6) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else if (theValue.charAt(3) != ':' || !(theValue.charAt(0) == '+' || theValue.charAt(0) == '-')) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else { parseInt(theWholeValue, theValue.substring(1, 3), 0, 23); parseInt(theWholeValue, theValue.substring(4, 6), 0, 59); clearTimeZone(); setTimeZone(TimeZone.getTimeZone("GMT" + theValue)); } return this; }
private BaseDateTimeDt setTimeZone(String theWholeValue, String theValue) { if (isBlank(theValue)) { throwBadDateFormat(theWholeValue); } else if (theValue.charAt(0) == 'Z') { clearTimeZone(); setTimeZoneZulu(true); } else if (theValue.length() != 6) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else if (theValue.charAt(3) != ':' || !(theValue.charAt(0) == '+' || theValue.charAt(0) == '-')) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else { parseInt(theWholeValue, theValue.substring(1, 3), 0, 23); parseInt(theWholeValue, theValue.substring(4, 6), 0, 59); clearTimeZone(); setTimeZone(TimeZone.getTimeZone("GMT" + theValue)); } return this; }
/** * Sets the value for this type using the given Java Date object as the time, and using the specified precision, as * well as the local timezone as determined by the local operating system. Both of * these properties may be modified in subsequent calls if neccesary. * * @param theValue * The date value * @param thePrecision * The precision * @throws DataFormatException */ public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException { if (getTimeZone() == null) { setTimeZone(TimeZone.getDefault()); } myPrecision = thePrecision; myFractionalSeconds = ""; if (theValue != null) { long millis = theValue.getTime() % 1000; if (millis < 0) { // This is for times before 1970 (see bug #444) millis = 1000 + millis; } String fractionalSeconds = Integer.toString((int) millis); myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0'); } super.setValue(theValue); }
time = value.substring(11, offsetIdx); String offsetString = value.substring(offsetIdx); setTimeZone(value, offsetString); cal.setTimeZone(getTimeZone());
/** * Constructor */ public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision, TimeZone theTimeZone) { this(theDate, thePrecision); setTimeZone(theTimeZone); }
/** * Sets the value for this type using the given Java Date object as the time, and using the specified precision, as * well as the local timezone as determined by the local operating system. Both of * these properties may be modified in subsequent calls if neccesary. * * @param theValue * The date value * @param thePrecision * The precision * @throws DataFormatException */ public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException { if (getTimeZone() == null) { setTimeZone(TimeZone.getDefault()); } myPrecision = thePrecision; myFractionalSeconds = ""; if (theValue != null) { long millis = theValue.getTime() % 1000; if (millis < 0) { // This is for times before 1970 (see bug #444) millis = 1000 + millis; } String fractionalSeconds = Integer.toString((int) millis); myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0'); } super.setValue(theValue); }
time = value.substring(11, offsetIdx); String offsetString = value.substring(offsetIdx); setTimeZone(value, offsetString); cal.setTimeZone(getTimeZone());