Search in sources :

Example 26 with TimeZone

use of java.util.TimeZone in project j2objc by google.

the class TimeZoneTest method testAllDisplayNames.

public void testAllDisplayNames() throws Exception {
    for (Locale locale : Locale.getAvailableLocales()) {
        for (String id : TimeZone.getAvailableIDs()) {
            TimeZone tz = TimeZone.getTimeZone(id);
            assertNotNull(tz.getDisplayName(false, TimeZone.LONG, locale));
        }
    }
}
Also used : Locale(java.util.Locale) TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone)

Example 27 with TimeZone

use of java.util.TimeZone in project j2objc by google.

the class TimeZoneTest method testPreHistoricInDaylightTime.

// http://code.google.com/p/android/issues/detail?id=14395
public void testPreHistoricInDaylightTime() throws Exception {
    Locale.setDefault(Locale.US);
    TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
    TimeZone.setDefault(tz);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    Date date = sdf.parse("1902-11-01T00:00:00.000+0800");
    assertEquals(-2119680000000L, date.getTime());
    assertEquals(-28800000, tz.getOffset(date.getTime()));
    assertFalse(tz.inDaylightTime(date));
    assertEquals("Fri Oct 31 08:00:00 PST 1902", date.toString());
    assertEquals("31 Oct 1902 16:00:00 GMT", date.toGMTString());
    // Any time before we have transition data is considered non-daylight, even in summer.
    date = sdf.parse("1902-06-01T00:00:00.000+0800");
    assertEquals(-28800000, tz.getOffset(date.getTime()));
    assertFalse(tz.inDaylightTime(date));
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 28 with TimeZone

use of java.util.TimeZone in project groovy-core by groovy.

the class TimeCategory method getDaylightSavingsOffset.

/**
     * Get the DST offset (if any) for the default locale and the given date.
     *
     * @param self a Date
     * @return the DST offset as a Duration.
     */
public static Duration getDaylightSavingsOffset(Date self) {
    TimeZone timeZone = getTimeZone(self);
    int millis = (timeZone.useDaylightTime() && timeZone.inDaylightTime(self)) ? timeZone.getDSTSavings() : 0;
    return new TimeDuration(0, 0, 0, millis);
}
Also used : TimeZone(java.util.TimeZone)

Example 29 with TimeZone

use of java.util.TimeZone in project groovy-core by groovy.

the class Dates method fromJsonDate.

public static Date fromJsonDate(char[] charArray, int from, int to) {
    try {
        if (isJsonDate(charArray, from, to)) {
            int year = CharScanner.parseIntFromTo(charArray, from + 0, from + 4);
            int month = CharScanner.parseIntFromTo(charArray, from + 5, from + 7);
            int day = CharScanner.parseIntFromTo(charArray, from + 8, from + 10);
            int hour = CharScanner.parseIntFromTo(charArray, from + 11, from + 13);
            int minute = CharScanner.parseIntFromTo(charArray, from + 14, from + 16);
            int second = CharScanner.parseIntFromTo(charArray, from + 17, from + 19);
            int miliseconds = CharScanner.parseIntFromTo(charArray, from + 20, from + 23);
            TimeZone tz = TimeZone.getTimeZone("GMT");
            return toDate(tz, year, month, day, hour, minute, second, miliseconds);
        } else {
            return null;
        }
    } catch (Exception ex) {
        return null;
    }
}
Also used : TimeZone(java.util.TimeZone)

Example 30 with TimeZone

use of java.util.TimeZone in project iosched by google.

the class SessionData method updateData.

public void updateData(Context context, String sessionName, String details, String sessionId, String imageUrl, String mainTag, long startTime, long endTime, String liveStreamId, String youTubeUrl, String tags, boolean inSchedule) {
    mSessionName = sessionName;
    mDetails = details;
    mSessionId = sessionId;
    mImageUrl = imageUrl;
    mMainTag = mainTag;
    TimeZone timeZone = SettingsUtils.getDisplayTimeZone(context);
    mStartDate = Calendar.getInstance();
    mStartDate.setTimeInMillis(startTime);
    mStartDate.setTimeZone(timeZone);
    mEndDate = Calendar.getInstance();
    mEndDate.setTimeInMillis(endTime);
    mEndDate.setTimeZone(timeZone);
    mLiveStreamId = liveStreamId;
    mYouTubeUrl = youTubeUrl;
    mTags = tags;
    mInSchedule = inSchedule;
}
Also used : TimeZone(java.util.TimeZone)

Aggregations

TimeZone (java.util.TimeZone)577 Date (java.util.Date)140 Calendar (java.util.Calendar)137 SimpleTimeZone (java.util.SimpleTimeZone)89 Test (org.junit.Test)85 SimpleDateFormat (java.text.SimpleDateFormat)69 Locale (java.util.Locale)69 GregorianCalendar (java.util.GregorianCalendar)56 ArrayList (java.util.ArrayList)32 DateFormat (java.text.DateFormat)24 ParseException (java.text.ParseException)23 IOException (java.io.IOException)20 Map (java.util.Map)15 HashSet (java.util.HashSet)13 PreparedStatement (java.sql.PreparedStatement)11 HashMap (java.util.HashMap)11 DateTimeZone (org.joda.time.DateTimeZone)11 Support_TimeZone (tests.support.Support_TimeZone)10 Resources (android.content.res.Resources)9 SQLException (java.sql.SQLException)9