dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
TimeFormat Struct Reference

Utility class for parsing and formatting dates and times in ISO-compatible format. More...

#include <TimeFormat.hpp>

Public Member Functions

const JavaObjectHandle< TimeFormat > & getHandle () const
std::int64_t parse (StringParam 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 DEFAULT_WITH_MILLIS
 The same as DEFAULT, with milliseconds.
static const TimeFormat DEFAULT_WITH_MILLIS_WITH_TIMEZONE
 The same as DEFAULT, with milliseconds and the timezone.
static const TimeFormat GMT
 An instance of TimeFormat that corresponds to GMT timezone as returned by Java TimeZone.getTimeZone("GMT").

Detailed Description

Utility class for parsing and formatting dates and times in ISO-compatible format.

Some methods that are not marked noexcept may throw exceptions:

Exceptions
InvalidArgumentExceptionif handle is invalid.
JavaExceptionif something happened with the dxFeed API backend
GraalExceptionif something happened with the GraalVM

Member Function Documentation

◆ format()

std::string TimeFormat::format ( std::int64_t timestamp) const

Converts timestamp into string according to the format.

Parameters
timestampThe date and time timestamp.
Returns
string representation of data and time or empty string on error

◆ getHandle()

const JavaObjectHandle< TimeFormat > & TimeFormat::getHandle ( ) const
Returns
The handle of the Java object of this time format, for the library's own use.

◆ parse()

std::int64_t TimeFormat::parse ( StringParam 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.
    • or any timezone that can be parsed by Java SimpleDateFormat.
Parameters
valueString value to parse.
Returns
Date's timestamp parsed from value or 0 if value has wrong format.