Logo Search packages:      
Sourcecode: icu version File versions  Download package

UDate DateFormat::parse ( const UnicodeString text,
UErrorCode status 
) const [virtual]

Parse a date/time string.

Parameters:
text The string to be parsed into a UDate value.
status Output param to be set to success/failure code. If 'text' cannot be parsed, it will be set to a failure code.
Returns:
The parsed UDate value, if successful. ICU 2.0

Reimplemented in RelativeDateFormat, and SimpleDateFormat.

Definition at line 268 of file datefmt.cpp.

References ParsePosition::getErrorIndex(), ParsePosition::getIndex(), U_FAILURE, and U_ILLEGAL_ARGUMENT_ERROR.

Referenced by SimpleDateFormat::parse(), RelativeDateFormat::parse(), parse(), parseObject(), DateFormatRegressionTest::Test4210209(), DateFormatTest::TestBadInput135(), DateFormatTest::TestDateFormatCalendar(), DateFormatTest::TestDateFormatZone061(), NumberFormatRegressionTest::TestJ691(), and IntlTestDateFormat::tryDate().

{
    if (U_FAILURE(status)) return 0;

    ParsePosition pos(0);
    UDate result = parse(text, pos);
    if (pos.getIndex() == 0) {
#if defined (U_DEBUG_CAL)
      fprintf(stderr, "%s:%d - - failed to parse  - err index %d\n"
              , __FILE__, __LINE__, pos.getErrorIndex() );
#endif
      status = U_ILLEGAL_ARGUMENT_ERROR;
    }
    return result;
}


Generated by  Doxygen 1.6.0   Back to index