Package com.microstrategy.utils
Class DateTimeConverter
- java.lang.Object
-
- com.microstrategy.utils.DateTimeConverter
-
public class DateTimeConverter extends java.lang.Object
The DateTimeConverter class will allow the user to change dates/times between GMT, which is what the I-Server returns timestamps in, and the local time zone of the end user. This class is meant to be used by those integrating the MicroStrategy Web Objects API with a Windows-based development environment such as ASP or Visual Basic.- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
serverPattern
The pattern of a date time string from the MicroStrategy Intelligence Server.
-
Constructor Summary
Constructors Constructor Description DateTimeConverter()
The constructor of DateTimeConverter is used to obtain an instance of this class, and initializes the locale to the default locale of the machine, the timezone to GMT.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
convert(java.lang.String iServerNeutralDateTime)
This method will take the locale and timezone indepenent string returned from the Intelligence Server and convert it to the locale and time zone which are set on this DateTimeConverter instance.static java.lang.String[]
getAvailableTimeZoneIDs()
This method will return the list of available time zone IDs.int
getLocaleID()
Returns the Windows LCID of the locale set on this object.static java.lang.String
getStringFromZonedDateTime(java.time.ZonedDateTime zonedDateTime, java.time.format.DateTimeFormatter dateTimeFormatter)
Returns the formatted version of String from ZonedDateTime using provided DateTimeFormatter.long
getTimestamp(java.lang.String iServerNeutralDateTim)
This method will convert a datetime string to a long million second timestampjava.lang.String
getTimeZoneID()
Returns the ID of the time zone which will be used when calling the convert method.static java.time.ZonedDateTime
getZonedDateTimeFromString(java.lang.String date)
Utility method to parse the date in String format which has time zone inDateTimeFormatter.ISO_ZONED_DATE_TIME
format i.e.void
setLocaleID(int localeID)
Sets the locale of this object by specifying the Windows LCID.void
setTimeZoneID(java.lang.String timezoneID)
This method sets the ID of the time zone which will be used to convert date/time values when the convert method is called.
-
-
-
Field Detail
-
serverPattern
public static final java.lang.String serverPattern
The pattern of a date time string from the MicroStrategy Intelligence Server.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DateTimeConverter
public DateTimeConverter()
The constructor of DateTimeConverter is used to obtain an instance of this class, and initializes the locale to the default locale of the machine, the timezone to GMT. These initial values can be changed after obtaining an instance of the object.
-
-
Method Detail
-
getLocaleID
public int getLocaleID()
Returns the Windows LCID of the locale set on this object. This will determine the locale that the date/time string will be formatted in after the conversion takes place.- Returns:
- The Windows LCID of the locale currently set on this object.
-
setLocaleID
public void setLocaleID(int localeID)
Sets the locale of this object by specifying the Windows LCID. This will determine the locale that the date/time string will be formatted in after the convert method is called- Parameters:
localeID
- The Windows LCID corresponding to the locale that the date should be formatted in.
-
getTimeZoneID
public java.lang.String getTimeZoneID()
Returns the ID of the time zone which will be used when calling the convert method. This value will be one of the values returned from the getAvailableTimeZoneIDs method.- Returns:
- The time zone ID which will be used upon calling convert.
-
setTimeZoneID
public void setTimeZoneID(java.lang.String timezoneID)
This method sets the ID of the time zone which will be used to convert date/time values when the convert method is called. This value must be one of the values returned from the getAvailableTimeZoneIDs method.- Parameters:
timezoneID
- The ID of the time zone to convert to.
-
convert
public java.lang.String convert(java.lang.String iServerNeutralDateTime) throws WebUtilsException
This method will take the locale and timezone indepenent string returned from the Intelligence Server and convert it to the locale and time zone which are set on this DateTimeConverter instance.- Parameters:
iServerNeutralDateTime
- The locale and time zone independent representation of a date/time from the Intelligence Server.- Returns:
- A locale-formatted, time zone adjusted, representation of the string passed to the method.
- Throws:
WebUtilsException
- Thrown if the conversion cannot take place.
-
getAvailableTimeZoneIDs
public static java.lang.String[] getAvailableTimeZoneIDs()
This method will return the list of available time zone IDs. The argument passed to setTimeZoneID and the value returned from getTimeZoneID must come from this list.- Returns:
- The list of available time zone IDs.
-
getTimestamp
public long getTimestamp(java.lang.String iServerNeutralDateTim) throws WebUtilsException
This method will convert a datetime string to a long million second timestamp- Parameters:
iServerNeutralDateTim
-- Returns:
- A timestamp in million seconds
- Throws:
WebUtilsException
-
getZonedDateTimeFromString
public static java.time.ZonedDateTime getZonedDateTimeFromString(java.lang.String date) throws WebUtilsException
Utility method to parse the date in String format which has time zone inDateTimeFormatter.ISO_ZONED_DATE_TIME
format i.e. 'YYYY-MM-DDTHH:MM:SS.SSS X' eg '2011-12-03T10:15:30+01:00'.- Parameters:
date
- String- Returns:
- ZonedDateTime instance
- Throws:
WebUtilsException
- Parsing failures
-
getStringFromZonedDateTime
public static java.lang.String getStringFromZonedDateTime(java.time.ZonedDateTime zonedDateTime, java.time.format.DateTimeFormatter dateTimeFormatter) throws WebUtilsException
Returns the formatted version of String from ZonedDateTime using provided DateTimeFormatter.- Parameters:
zonedDateTime
- ZonedDateTimedateTimeFormatter
- DateTimeFormatter- Returns:
- String
- Throws:
WebUtilsException
-
-