dxFeed Graal CXX API
|
Utility class for parsing and formatting dates and times in ISO-compatible format. More...
#include <TimeFormat.hpp>
Public Member Functions | |
std::int64_t | parse (const std::string &value) const |
Reads Date from String and returns timestamp. | |
std::string | format (std::int64_t timestamp) const |
Converts timestamp into string according to the format. | |
Static Public Attributes | |
static const TimeFormat | DEFAULT |
An instance of TimeFormat that corresponds to default timezone as returned by TimeZone::getDefault() method. | |
static const TimeFormat | GMT |
An instance of TimeFormat that corresponds to GMT timezone as returned by TimeZone::getTimeZone("GMT"). | |
Utility class for parsing and formatting dates and times in ISO-compatible format.
Some methods that are not marked noexcept
may throw exceptions:
std::invalid_argument | if handle is invalid. |
JavaException | if something happened with the dxFeed API backend |
GraalException | if something happened with the GraalVM |
std::string TimeFormat::format | ( | std::int64_t | timestamp | ) | const |
Converts timestamp into string according to the format.
timestamp | The date and time timestamp. |
std::int64_t TimeFormat::parse | ( | const std::string & | value | ) | const |
Reads Date from String and returns timestamp.
This method is designed to understand ISO 8601 formatted date and time. It accepts the following formats:
0
is parsed as zero time. '-'<time-period>
it is parsed as <current time> - <time-period>. <long-value-in-milliseconds>
It should be positive and have at least 9 digits (otherwise it could not be distinguished from date in format 'yyyymmdd'
). Each date since 1970-01-03 can be represented in this form. <date>[('T'|'t'|'-'|' ')<time>][<timezone>]
If time is missing it is supposed to be '00:00:00'
. ['T'|'t']<time>[<timezone>]
In this case current date is used. Here
<date>
is one of yyyy-MM-dd
yyyyMMdd
<time>
is one of HH:mm:ss[.sss]
HHmmss[.sss]
HH:mm
HHmm
HH
<timezone>
is one of [+-]HH:mm
[+-]HHmm
[+-]HH
Z
for UTC. value | String value to parse. |
value
or 0
if value
has wrong format.