We're updating the issue view to help you get more done. 

Bug in date parsing.

Description

I use a SimpleDateFormat object with the language english. I call ApplyPattern
with the format "MMMM d yy". When I try to parse the string " 04 05 06", it
works ?

?

?

The UDATE result is 1104814800000.0 (wich correspond to january 4 2005) and the
ParsePosition parameter after the parse call is pp.Index = 6 and pp.errorIndex =
-1!!!!

The problem seems to be with the 1st character of the string to be parsed (it's
a space) because if I try to parse the string "04 05 06" it fails.

Here is a simple code that shows the bug:

void CICUDlg::OnGo()
{
std::wstring wsData = L"MMMM d yy";
std::wstring wsParse = L" 04 05 06";

UErrorCode status = U_ZERO_ERROR;
Locale lLoc("en");
SimpleDateFormat sdfObj(L"", lLoc, status );

sdfObj.applyPattern(wsData.data());

ParsePosition pp(0);

UDate udDate = sdfObj.parse(wsParse.data(), pp );
if(pp.getErrorIndex() == -1)
{
status = U_ZERO_ERROR;
SimpleDateFormat formatter(L"yyyy MM dd", Locale::getEnglish(), status );

UnicodeString usFormatted;

FieldPosition fp(0);

formatter.format(udDate, usFormatted,fp);

CString csFormatted(usFormatted.getBuffer(), usFormatted.length());

MessageBox(csFormatted);
}
}

Status

Assignee

TracBot

Reporter

TracBot

Labels

Reviewer

None

Time Needed

None

Start date

None

Components

Fix versions

Priority

major