public class ISO8601 extends 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).
Modifier and Type | Field and Description |
---|---|
private static long |
day |
private static long |
hour |
private static Calendar |
localCal |
private static char |
minus |
private static long |
minute |
private static long |
month |
private static char |
plus |
private static long |
sec |
private static char |
t |
private static Calendar |
utcCal |
private static long |
year |
private static String |
z |
Constructor and Description |
---|
ISO8601()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private static String |
formatlocalDate(Date d) |
private static String |
formatutcDate(Date d) |
static void |
main(String[] argv)
The main is here only for debugging.
|
private static Date |
parselocalDateFormat(String dateTimeToken)
parse a date time token in local format (i.e.
|
private static Date |
parseutcDateFormat(String dateTimeToken)
parse a date time token in UTC format (i.e.
|
private static String |
subFormatDate(Calendar cal) |
private static void |
subparse(Calendar cal,
String dateTimeToken) |
static Date |
toDate(String dateTimeToken)
This method converts a FIPA DateTime token to a
java.util.Date . |
static String |
toRelativeTimeString(long millisec)
this method converts into a string in ISO8601 format representing
relative time from the current time
|
static String |
toString(Date d)
This method converts a
java.util.Date into a FIPA DateTime
token by using the UTC time. |
static String |
toString(Date d,
boolean useUTCtime)
This method converts a
java.util.Date into a FIPA DateTime token. |
private static String |
zeroPaddingNumber(long value,
int digits) |
private static Calendar localCal
private static Calendar utcCal
private static char plus
private static char minus
private static String z
private static char t
private static final long year
private static final long month
private static final long day
private static final long hour
private static final long minute
private static final long sec
private static Date parseutcDateFormat(String dateTimeToken) throws Exception
Exception
private static Date parselocalDateFormat(String dateTimeToken) throws Exception
Exception
public static Date toDate(String dateTimeToken) throws Exception
java.util.Date
.
It will accept both local and UTC time formats.an
- Exception if the String is not a valid dateTimeException
public static String toString(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 String toString(Date d)
java.util.Date
into a FIPA DateTime
token by using the UTC time.public static String toRelativeTimeString(long millisec)
millisec
- is the number of milliseconds from nowprivate static String zeroPaddingNumber(long value, int digits)
public static void main(String[] argv)
java jade.lang.acl.ISO8601