本文整理汇总了C++中SimpleDateFormat::get2DigitYearStart方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleDateFormat::get2DigitYearStart方法的具体用法?C++ SimpleDateFormat::get2DigitYearStart怎么用?C++ SimpleDateFormat::get2DigitYearStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleDateFormat
的用法示例。
在下文中一共展示了SimpleDateFormat::get2DigitYearStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleDateFormat
/**
* @bug 4056591
* Verify the function of the [s|g]et2DigitYearStart() API.
*/
void DateFormatRegressionTest::Test4056591(void)
{
UErrorCode status = U_ZERO_ERROR;
//try {
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("yyMMdd"), Locale::getUS(), status);
if (failure(status, "new SimpleDateFormat", TRUE)) {
delete fmt;
return;
}
UDate start = date(1809-1900, UCAL_DECEMBER, 25);
fmt->set2DigitYearStart(start, status);
failure(status, "fmt->setTwoDigitStartDate");
if( (fmt->get2DigitYearStart(status) != start) || failure(status, "get2DigitStartDate"))
errln("get2DigitYearStart broken");
UDate dates [] = {
date(1809-1900, UCAL_DECEMBER, 25),
date(1909-1900, UCAL_DECEMBER, 24),
date(1809-1900, UCAL_DECEMBER, 26),
date(1861-1900, UCAL_DECEMBER, 25),
};
UnicodeString strings [] = {
(UnicodeString) "091225",
(UnicodeString) "091224",
(UnicodeString) "091226",
(UnicodeString) "611225"
};
/*Object[] DATA = {
"091225", new Date(1809-1900, Calendar.DECEMBER, 25),
"091224", new Date(1909-1900, Calendar.DECEMBER, 24),
"091226", new Date(1809-1900, Calendar.DECEMBER, 26),
"611225", new Date(1861-1900, Calendar.DECEMBER, 25),
};*/
for(int i = 0; i < 4; i++) {
UnicodeString s = strings[i];
UDate exp = dates[i];
UDate got = fmt->parse(s, status);
failure(status, "fmt->parse");
logln(s + " -> " + got + "; exp " + exp);
if(got != exp)
errln("set2DigitYearStart broken");
}
/*}
catch (ParseException e) {
errln("Fail: " + e);
e.printStackTrace();
}*/
delete fmt;
}