Class DtObj

All Implemented Interfaces:
AutoCloseable

public class DtObj extends ChilkatObject
<section class="dtobj-summary">

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 Details

    • DtObj

      public DtObj()
      Creates a new DtObj object.
  • 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 Day property
    • setDay

      public void setDay​(int value)
      Sets the Day property; see getDay().
      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 Hour property
    • setHour

      public void setHour​(int value)
      Sets the Hour property; see getHour().
      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 Minute property
    • setMinute

      public void setMinute​(int value)
      Sets the Minute property; see getMinute().
      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 Month property
    • setMonth

      public void setMonth​(int value)
      Sets the Month property; see getMonth().
      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 Second property
    • setSecond

      public void setSecond​(int value)
      Sets the Second property; see getSecond().
      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 StructTmMonth property
    • setStructTmMonth

      public void setStructTmMonth​(int value)
      Sets the StructTmMonth property; see getStructTmMonth().
      Parameters:
      value - the new value
    • getStructTmYear

      public int getStructTmYear()
      The year represented as the number of years since 1900.
      Returns:
      the value of the StructTmYear property
    • setStructTmYear

      public void setStructTmYear​(int value)
      Sets the StructTmYear property; see getStructTmYear().
      Parameters:
      value - the new value
    • getUtc

      public boolean getUtc()
      true if this is a UTC time, otherwise false if this is a local time.
      Returns:
      the value of the Utc property
    • setUtc

      public void setUtc​(boolean value)
      Sets the Utc property; see getUtc().
      Parameters:
      value - the new value
    • getYear

      public int getYear()
      The year, such as 2012.
      Returns:
      the value of the Year property
    • setYear

      public void setYear​(int value)
      Sets the Year property; see getYear().
      Parameters:
      value - the new value
    • deSerialize

      public void deSerialize​(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.
      Parameters:
      serializedDtObj - the serializedDtObj argument (not null)
    • serialize

      public String 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