Class CosemDate

  • All Implemented Interfaces:
    CosemDateFormat

    public class CosemDate
    extends java.lang.Object
    implements CosemDateFormat
    Class representing a COSEM Date.
    • Constructor Summary

      Constructors 
      Constructor Description
      CosemDate​(int year, int month, int dayOfMonth)
      Constructs a COSEM Date.
      CosemDate​(int year, int month, int dayOfMonth, int dayOfWeek)
      Constructs a COSEM Date.
      CosemDate​(int year, CosemDate.Month month, int dayOfMonth)
      Constructs a COSEM Date.
    • Constructor Detail

      • CosemDate

        public CosemDate​(int year,
                         int month,
                         int dayOfMonth)
        Constructs a COSEM Date.
        Parameters:
        year - the year from 0 to 0xffff.
        month - the month from 1 to 12. Set to 0xff if not specified.
        dayOfMonth - the day of the month starting from 1 to max 31. Set to 0xfe for the last day of a month and 0xfd for the second last day of a month. Set to 0xff if not specified.
        Throws:
        java.lang.IllegalArgumentException - if a parameter does not fit the range
      • CosemDate

        public CosemDate​(int year,
                         CosemDate.Month month,
                         int dayOfMonth)
        Constructs a COSEM Date.
        Parameters:
        year - the year from 0 to 0xffff.
        month - the month
        dayOfMonth - the day of the month starting from 1 to max 31. Set to 0xfe for the last day of a month and 0xfd for the second last day of a month. Set to 0xff if not specified.
        Throws:
        java.lang.IllegalArgumentException - if a parameter does not fit the range
      • CosemDate

        public CosemDate​(int year,
                         int month,
                         int dayOfMonth,
                         int dayOfWeek)
        Constructs a COSEM Date.
        Parameters:
        year - the year from 0 to 0xffff.
        month - the month from 1 to 12. Set to 0xff if not specified.
        dayOfMonth - the day of the month starting from 1 to max 31. Set to 0xfe for the last day of a month and 0xfd for the second last day of a month. Set to 0xff if not specified.
        dayOfWeek - the day of a week from 1 to 7. 1 is Monday. Set to 0xff if not specified or use CosemDate(int, int, int)
        Throws:
        java.lang.IllegalArgumentException - if a parameter does not fit the range
    • Method Detail

      • decode

        public static CosemDate decode​(java.io.InputStream stream)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • decode

        public static CosemDate decode​(byte[] octetString)
      • encode

        public byte[] encode()
        Description copied from interface: CosemDateFormat
        The octet string.
        Specified by:
        encode in interface CosemDateFormat
        Returns:
        the octet string.
      • length

        public int length()
        Description copied from interface: CosemDateFormat
        The size of the octet string.
        Specified by:
        length in interface CosemDateFormat
        Returns:
        the size.
      • get

        public int get​(CosemDateFormat.Field field)
        Description copied from interface: CosemDateFormat
        Retrieves the value for a certain value.
        Specified by:
        get in interface CosemDateFormat
        Parameters:
        field - the field which should be retrieved.
        Returns:
        the value as an int32.