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

TimeZone *U_EXPORT2 TimeZone::createTimeZone ( const UnicodeString ID  )  [static, inherited]

Creates a TimeZone for the given ID.

Parameters:
ID the ID for a TimeZone, such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".
Returns:
the specified TimeZone, or the GMT zone if the given ID cannot be understood. Return result guaranteed to be non-null. If you require that the specific zone asked for be returned, check the ID of the return result. ICU 2.0

Definition at line 460 of file timezone.cpp.

References TimeZone::clone(), TimeZone::createCustomTimeZone(), TimeZone::createSystemTimeZone(), TimeZone::getGMT(), and NULL.

Referenced by createVTimeZoneByID(), SimpleDateFormat::initGMTFormatters(), SimpleDateFormat::subParse(), CalendarRegressionTest::test4031502(), CalendarRegressionTest::test4061476(), DateFormatRegressionTest::Test4065240(), TimeZoneRegressionTest::Test4073209(), CalendarRegressionTest::test4083167(), TimeZoneRegressionTest::Test4084933(), CalendarRegressionTest::test4086724(), CalendarRegressionTest::test4096231(), DateFormatRegressionTest::Test4103341(), TimeZoneRegressionTest::Test4109314(), CalendarRegressionTest::test4114578(), TimeZoneRegressionTest::Test4126678(), CalendarRegressionTest::test4145158(), CalendarRegressionTest::test4145983(), CalendarRegressionTest::Test4149677(), CalendarRegressionTest::Test4162587(), IntlTestDateTimePatternGeneratorAPI::testAPI(), TimeZoneBoundaryTest::TestBoundaries(), TimeZoneTest::TestCountries(), TimeZoneTest::TestCustomParse(), DateFormatTest::TestDateFormatZone061(), DateFormatTest::TestDateFormatZone146(), TimeZoneTest::TestDisplayName(), DateFormatTest::TestEquals(), DateFormatTest::TestFieldPosition(), TimeZoneTest::TestGenericAPI(), TimeZoneTest::TestGetAvailableIDs913(), TimeZoneRegressionTest::TestJ449(), CalendarRegressionTest::TestJ81(), TimeZoneTest::TestPRTOffset(), TimeZoneTest::TestShortZoneIDs(), TimeZoneBoundaryTest::TestStepwise(), CalendarRegressionTest::TestTimeZoneTransitionAdd(), DateFormatTest::TestTwoDigitYearDSTParse(), TimeZoneTest::TestVariousAPI518(), DateFormatTest::TestWallyWedel(), CalendarRegressionTest::TestWeekShift(), and udat_open().

{
    /* We first try to lookup the zone ID in our system list.  If this
     * fails, we try to parse it as a custom string GMT[+-]hh:mm.  If
     * all else fails, we return GMT, which is probably not what the
     * user wants, but at least is a functioning TimeZone object.
     *
     * We cannot return NULL, because that would break compatibility
     * with the JDK.
     */
    TimeZone* result = createSystemTimeZone(ID);

    if (result == 0) {
        U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to custom"));
        result = createCustomTimeZone(ID);
    }
    if (result == 0) {
        U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to GMT"));
        const TimeZone* temptz = getGMT();
        if (temptz == NULL) {
            result = NULL;
        } else {
            result = temptz->clone();
        }
    }
    return result;
}


Generated by  Doxygen 1.6.0   Back to index