/** * Sets the value for this type using the given Java Date object as the time, and using the default precision for * this datatype (unless the precision is already set), 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. */ @Override public BaseDateTimeDt setValue(Date theValue) { setValue(theValue, getPrecision()); return this; }
/** * Constructor * * @throws DataFormatException * If the specified precision is not allowed for this type */ public BaseDateTimeDt(String theString) { setValueAsString(theString); validatePrecisionAndThrowDataFormatException(theString, getPrecision()); }
/** * Returns a human readable version of this date/time using the system local format. * <p> * <b>Note on time zones:</b> This method renders the value using the time zone that is contained within the value. * For example, if this date object contains the value "2012-01-05T12:00:00-08:00", * the human display will be rendered as "12:00:00" even if the application is being executed on a system in a * different time zone. If this behaviour is not what you want, use * {@link #toHumanDisplayLocalTimezone()} instead. * </p> */ public String toHumanDisplay() { TimeZone tz = getTimeZone(); Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance(); value.setTime(getValue()); switch (getPrecision()) { case YEAR: case MONTH: case DAY: return ourHumanDateFormat.format(value); case MILLI: case SECOND: default: return ourHumanDateTimeFormat.format(value); } }
/** * Returns a human readable version of this date/time using the system local format, converted to the local timezone * if neccesary. * * @see #toHumanDisplay() for a method which does not convert the time to the local timezone before rendering it. */ public String toHumanDisplayLocalTimezone() { switch (getPrecision()) { case YEAR: case MONTH: case DAY: return ourHumanDateFormat.format(getValue()); case MILLI: case SECOND: default: return ourHumanDateTimeFormat.format(getValue()); } }
/** * Sets the value for this type using the given Java Date object as the time, and using the default precision for * this datatype (unless the precision is already set), 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. */ @Override public BaseDateTimeDt setValue(Date theValue) { setValue(theValue, getPrecision()); return this; }
/** * Constructor * * @throws DataFormatException * If the specified precision is not allowed for this type */ public BaseDateTimeDt(String theString) { setValueAsString(theString); validatePrecisionAndThrowDataFormatException(theString, getPrecision()); }
/** * Returns a human readable version of this date/time using the system local format. * <p> * <b>Note on time zones:</b> This method renders the value using the time zone that is contained within the value. * For example, if this date object contains the value "2012-01-05T12:00:00-08:00", * the human display will be rendered as "12:00:00" even if the application is being executed on a system in a * different time zone. If this behaviour is not what you want, use * {@link #toHumanDisplayLocalTimezone()} instead. * </p> */ public String toHumanDisplay() { TimeZone tz = getTimeZone(); Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance(); value.setTime(getValue()); switch (getPrecision()) { case YEAR: case MONTH: case DAY: return ourHumanDateFormat.format(value); case MILLI: case SECOND: default: return ourHumanDateTimeFormat.format(value); } }
/** * Returns a human readable version of this date/time using the system local format, converted to the local timezone * if neccesary. * * @see #toHumanDisplay() for a method which does not convert the time to the local timezone before rendering it. */ public String toHumanDisplayLocalTimezone() { switch (getPrecision()) { case YEAR: case MONTH: case DAY: return ourHumanDateFormat.format(getValue()); case MILLI: case SECOND: default: return ourHumanDateTimeFormat.format(getValue()); } }