public class ISO8601
extends java.lang.Object
java.text.SimpleDateFormat
notation, it is:
yyyyMMdd'T'HHmmssSSS'Z'
, where the 'T'
serves to separate the Day from the Time,
and the 'Z'
indicates that the time is in UTC.
The FIPA specs permit either local or UTC time, however, they do
express a preference for UTC time (this is particularly helpful when
passing messages between agents running on machines in different timezones).
toString(false)
is called).
Constructor and Description |
---|
ISO8601()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] argv)
The main is here only for debugging.
|
static java.util.Date |
toDate(java.lang.String dateTimeToken)
This method converts a FIPA DateTime token to a
java.util.Date . |
static java.lang.String |
toRelativeTimeString(long millisec)
this method converts into a string in ISO8601 format representing
relative time from the current time
|
static java.lang.String |
toString(java.util.Date d)
This method converts a
java.util.Date into a FIPA DateTime
token by using the UTC time. |
static java.lang.String |
toString(java.util.Date d,
boolean useUTCtime)
This method converts a
java.util.Date into a FIPA DateTime token. |
public static java.util.Date toDate(java.lang.String dateTimeToken) throws java.lang.Exception
java.util.Date
.
It will accept both local and UTC time formats.an
- Exception if the String is not a valid dateTimejava.lang.Exception
public static java.lang.String toString(java.util.Date d, boolean useUTCtime)
java.util.Date
into a FIPA DateTime token.
Note: the current default behaviour is to generate dates in UTC time.
see ISO8601.useUTCtime
for details.useUTCtime
- controls the style used by toString
,
'true' generates tokens using UTC time, 'false' using local time.
If you need to send messages to agents compiled with older versions
of Jade, then set this to false
.public static java.lang.String toString(java.util.Date d)
java.util.Date
into a FIPA DateTime
token by using the UTC time.public static java.lang.String toRelativeTimeString(long millisec)
millisec
- is the number of milliseconds from nowpublic static void main(java.lang.String[] argv)
java jade.lang.acl.ISO8601