Class DtObj
- All Implemented Interfaces:
AutoCloseable
Represent a date/time as simple editable fields.
Chilkat.DtObj is a lightweight date/time value object used by
Chilkat methods that need to pass or return individual date and time fields.
It stores values such as year, month, day, hour, minute, and second, along
with a flag indicating whether the value represents UTC or local time. It
also provides a compact serialization format for saving and restoring the
date/time value.
Simple date fields
Store and edit the year, month, day, hour, minute, and second as individual properties.
UTC or local time
Use the UTC flag to indicate whether the stored fields represent UTC or local time.
Struct tm compatibility
Use alternate month and year properties when working with
struct tm-style date/time conventions.
Serialize and restore
Save and restore the object using Chilkat's compact internal serialized date/time representation.
Used by other classes
Pass DtObj values to Chilkat methods that require explicit
date/time fields or return date/time information.
Small and focused
Use this class as a simple container rather than a full date/time calculation or timezone-conversion engine.
Common pattern:
Create or receive a DtObj, set or read the individual date/time
fields, check whether the value is UTC or local time, and pass the object to
another Chilkat method. Use serialization only when the date/time value needs
to be saved and restored in Chilkat's compact internal format.
For an extended overview, see DtObj Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeSerialize(String serializedDtObj)Loads the date/time with a string having the format as produced by the Serialize method, which is a string of SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1/0.intgetDay()The day of the month.intgetHour()The hour.intThe minute.intgetMonth()The month.intThe second.intThe month.intThe year represented as the number of years since 1900.booleangetUtc()trueif this is a UTC time, otherwisefalseif this is a local time.intgetYear()The year, such as 2012.Serializes the date/time to a us-ascii string that can be imported at a later time via the DeSerialize method.voidsetDay(int value)Sets theDayproperty; seegetDay().voidsetHour(int value)Sets theHourproperty; seegetHour().voidsetMinute(int value)Sets theMinuteproperty; seegetMinute().voidsetMonth(int value)Sets theMonthproperty; seegetMonth().voidsetSecond(int value)Sets theSecondproperty; seegetSecond().voidsetStructTmMonth(int value)Sets theStructTmMonthproperty; seegetStructTmMonth().voidsetStructTmYear(int value)Sets theStructTmYearproperty; seegetStructTmYear().voidsetUtc(boolean value)Sets theUtcproperty; seegetUtc().voidsetYear(int value)Sets theYearproperty; seegetYear().Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
DtObj
public DtObj()Creates a newDtObjobject.
-
-
Method Details
-
getDay
public int getDay()The day of the month. The valid values for this member are 1 through 31.- Returns:
- the value of the
Dayproperty
-
setDay
public void setDay(int value)Sets theDayproperty; seegetDay().- Parameters:
value- the new value
-
getHour
public int getHour()The hour. The valid values for this member are 0 through 23.- Returns:
- the value of the
Hourproperty
-
setHour
public void setHour(int value)Sets theHourproperty; seegetHour().- Parameters:
value- the new value
-
getMinute
public int getMinute()The minute. The valid values for this member are 0 through 59.- Returns:
- the value of the
Minuteproperty
-
setMinute
public void setMinute(int value)Sets theMinuteproperty; seegetMinute().- Parameters:
value- the new value
-
getMonth
public int getMonth()The month. The valid values for this member are 1 through 12 where 1 = January and 12 = December.- Returns:
- the value of the
Monthproperty
-
setMonth
public void setMonth(int value)Sets theMonthproperty; seegetMonth().- Parameters:
value- the new value
-
getSecond
public int getSecond()The second. The valid values for this member are 0 through 59.- Returns:
- the value of the
Secondproperty
-
setSecond
public void setSecond(int value)Sets theSecondproperty; seegetSecond().- Parameters:
value- the new value
-
getStructTmMonth
public int getStructTmMonth()The month. The valid values for this member are 0 through 11 where 0 = January and 11 = December.- Returns:
- the value of the
StructTmMonthproperty
-
setStructTmMonth
public void setStructTmMonth(int value)Sets theStructTmMonthproperty; seegetStructTmMonth().- Parameters:
value- the new value
-
getStructTmYear
public int getStructTmYear()The year represented as the number of years since 1900.- Returns:
- the value of the
StructTmYearproperty
-
setStructTmYear
public void setStructTmYear(int value)Sets theStructTmYearproperty; seegetStructTmYear().- Parameters:
value- the new value
-
getUtc
public boolean getUtc()trueif this is a UTC time, otherwisefalseif this is a local time.- Returns:
- the value of the
Utcproperty
-
setUtc
public void setUtc(boolean value)Sets theUtcproperty; seegetUtc().- Parameters:
value- the new value
-
getYear
public int getYear()The year, such as 2012.- Returns:
- the value of the
Yearproperty
-
setYear
public void setYear(int value)Sets theYearproperty; seegetYear().- Parameters:
value- the new value
-
deSerialize
Loads the date/time with a string having the format as produced by the Serialize method, which is a string of SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1/0.- Parameters:
serializedDtObj- theserializedDtObjargument (notnull)
-
serialize
Serializes the date/time to a us-ascii string that can be imported at a later time via the DeSerialize method. The format of the string returned by this method is not intended to match any published standard. It is formatted to a string with SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1/0.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-