Logo Search packages:      
Sourcecode: icu version File versions

void SimpleDateFormat::initialize ( const Locale locale,
UErrorCode status 
) [private]

Called by construct() and the various constructors to set up the SimpleDateFormat's Calendar and NumberFormat objects.

Parameters:
localeThe locale for which we want a Calendar and a NumberFormat.
statusFilled in with an error code if creating either subobject fails.

Definition at line 735 of file smpdtfmt.cpp.

References DateFormat::createInstance(), FALSE, DateFormat::fNumberFormat, initNumberFormatters(), NULL, DecimalFormat::setDecimalSeparatorAlwaysShown(), NumberFormat::setGroupingUsed(), NumberFormat::setMinimumFractionDigits(), NumberFormat::setParseIntegerOnly(), TRUE, U_FAILURE, U_MISSING_RESOURCE_ERROR, and U_SUCCESS.

Referenced by construct(), and SimpleDateFormat().

{
    if (U_FAILURE(status)) return;

    // We don't need to check that the row count is >= 1, since all 2d arrays have at
    // least one row
    fNumberFormat = NumberFormat::createInstance(locale, status);
    if (fNumberFormat != NULL && U_SUCCESS(status))
    {
        // no matter what the locale's default number format looked like, we want
        // to modify it so that it doesn't use thousands separators, doesn't always
        // show the decimal point, and recognizes integers only when parsing

        fNumberFormat->setGroupingUsed(FALSE);
        DecimalFormat* decfmt = dynamic_cast<DecimalFormat*>(fNumberFormat);
        if (decfmt != NULL) {
            decfmt->setDecimalSeparatorAlwaysShown(FALSE);
        }
        fNumberFormat->setParseIntegerOnly(TRUE);
        fNumberFormat->setMinimumFractionDigits(0); // To prevent "Jan 1.00, 1997.00"

        //fNumberFormat->setLenient(TRUE); // Java uses a custom DateNumberFormat to format/parse

        initNumberFormatters(locale,status);

    }
    else if (U_SUCCESS(status))
    {
        status = U_MISSING_RESOURCE_ERROR;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index