Skip to content

SyntaxException for DateTimeParser::parse not working #569

@aleks-f

Description

@aleks-f

From http://stackoverflow.com/questions/25285740/syntex-exception-for-datetimeparserparse-of-poco-not-working :

In the documentation to Poco::DateTimeParser:.parse(const
std::string& fmt, const std::string& str, int& timeZoneDifferential)

Parses a date and time in the given format from the given string.
Throws a SyntaxException if the string cannot be successfully parsed.

As I understand this sentence the given datestring "str" must be in
the format described in paramter "fmt", otherwise a SyntaxException is thrown - or do I miss something ?

But even if i give wrong format like "sjdcg-12987-kjchsjkc" or an empty format. its parsing the string and giving some garbage value.

How can i solve this issue:

the code is like this-

string datetime="jnghjgnbcfjb";

try
{
  DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT,datetime,dt,tzd);
}
catch(const Poco::Exception& exc)
{
  cout << exc.displayText() << endl;
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions