dxFeed Graal CXX API
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

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").
 

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
std::invalid_argumentif 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

◆ parse()

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.
    • 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.