jade.lang.acl
Class ISO8601
java.lang.Object
|
+--jade.lang.acl.ISO8601
- public class ISO8601
- extends java.lang.Object
This class contains a set of static methods that convert
to/from the Date Time format adopted by FIPA.
The FIPA format is based on ISO8601, with the addition of milliseconds.
Using the 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).
- Older versions of this code:
- read DateTime as local time
- wrote DateTime as local time
- Current versions of this code:
- read DateTime in both local time and UTC time
- write DateTime as UTC time by default (can generate local time
if
toString(false)
is called).
- Version:
- $Date: 2003/02/20 14:29:03 $ $Revision: 2.6 $
Modified by:
- Author:
- Fabio Bellifemine - CSELT, Craig Sayers, HP Labs, Palo Alto, California
Method Summary |
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.
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ISO8601
public ISO8601()
toDate
public static java.util.Date toDate(java.lang.String dateTimeToken)
throws java.lang.Exception
- This method converts a FIPA DateTime token to a
java.util.Date
.
It will accept both local and UTC time formats.
- Returns:
- an absolute value of DateTime
- Throws:
- an - Exception if the String is not a valid dateTime
toString
public static java.lang.String toString(java.util.Date d,
boolean useUTCtime)
- This method converts a
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.
- Parameters:
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
.- Returns:
- a String, e.g. "19640625T073000000Z" to represent 7:30AM on the
25th of June of 1964, UTC time.
toString
public 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.
- Returns:
- a String, e.g. "19640625T073000000Z" to represent 7:30AM on the
25th of June of 1964, UTC time.
toRelativeTimeString
public static java.lang.String toRelativeTimeString(long millisec)
- this method converts into a string in ISO8601 format representing
relative time from the current time
- Parameters:
millisec
- is the number of milliseconds from now- Returns:
- a String, e.g. "+00000000T010000000" to represent one hour
from now
main
public static void main(java.lang.String[] argv)
- The main is here only for debugging.
You can test your conversion by executing the following command:
java jade.lang.acl.ISO8601