/** * Sets the value of this instant to the current time (from the system * clock) and the local/default timezone (as retrieved using * {@link TimeZone#getDefault()}. This TimeZone is generally obtained from * the underlying OS. */ public void setToCurrentTimeInLocalTimeZone() { setValue(new Date()); setTimeZone(TimeZone.getDefault()); }
/** * Create a new DateTimeDt using an existing value. <b>Use this constructor with caution</b>, * as it may create more precision than warranted (since for example it is possible to pass in * a DateTime with only a year, and this constructor will convert to an InstantDt with * milliseconds precision). */ public InstantDt(BaseDateTimeDt theDateTime) { // Do not call super(foo) here, we don't want to trigger a DataFormatException setValue(theDateTime.getValue()); setPrecision(DEFAULT_PRECISION); setTimeZone(theDateTime.getTimeZone()); }
/** * Constructor which accepts a date value and a precision value. Valid * precisions values for this type are: * <ul> * <li>{@link TemporalPrecisionEnum#SECOND} * <li>{@link TemporalPrecisionEnum#MILLI} * </ul> */ @SimpleSetter public InstantDt(@SimpleSetter.Parameter(name = "theDate") Date theDate, @SimpleSetter.Parameter(name = "thePrecision") TemporalPrecisionEnum thePrecision) { setValue(theDate); setPrecision(thePrecision); setTimeZone(TimeZone.getDefault()); }
/** * Sets the value of this instant to the current time (from the system * clock) and the local/default timezone (as retrieved using * {@link TimeZone#getDefault()}. This TimeZone is generally obtained from * the underlying OS. */ public void setToCurrentTimeInLocalTimeZone() { setValue(new Date()); setTimeZone(TimeZone.getDefault()); }
/** * Create a new DateTimeDt using an existing value. <b>Use this constructor with caution</b>, * as it may create more precision than warranted (since for example it is possible to pass in * a DateTime with only a year, and this constructor will convert to an InstantDt with * milliseconds precision). */ public InstantDt(BaseDateTimeDt theDateTime) { // Do not call super(foo) here, we don't want to trigger a DataFormatException setValue(theDateTime.getValue()); setPrecision(DEFAULT_PRECISION); setTimeZone(theDateTime.getTimeZone()); }
/** * Constructor which accepts a date value and a precision value. Valid * precisions values for this type are: * <ul> * <li>{@link TemporalPrecisionEnum#SECOND} * <li>{@link TemporalPrecisionEnum#MILLI} * </ul> */ @SimpleSetter public InstantDt(@SimpleSetter.Parameter(name = "theDate") Date theDate, @SimpleSetter.Parameter(name = "thePrecision") TemporalPrecisionEnum thePrecision) { setValue(theDate); setPrecision(thePrecision); setTimeZone(TimeZone.getDefault()); }