Package org.openmuc.jdlms.datatypes
Class CosemDate
- java.lang.Object
-
- org.openmuc.jdlms.datatypes.CosemDate
-
- All Implemented Interfaces:
CosemDateFormat
public class CosemDate extends java.lang.Object implements CosemDateFormat
Class representing a COSEM Date.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CosemDate.Month
-
Nested classes/interfaces inherited from interface org.openmuc.jdlms.datatypes.CosemDateFormat
CosemDateFormat.Field
-
-
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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CosemDate
decode(byte[] octetString)
static CosemDate
decode(java.io.InputStream stream)
byte[]
encode()
The octet string.int
get(CosemDateFormat.Field field)
Retrieves the value for a certain value.int
length()
The size of the octet string.
-
-
-
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 monthdayOfMonth
- 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 useCosemDate(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 interfaceCosemDateFormat
- Returns:
- the octet string.
-
length
public int length()
Description copied from interface:CosemDateFormat
The size of the octet string.- Specified by:
length
in interfaceCosemDateFormat
- 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 interfaceCosemDateFormat
- Parameters:
field
- the field which should be retrieved.- Returns:
- the value as an int32.
-
-