TimeZone setDefault - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TimeZone setDefault method.

This code example shows how to use the following methods:setDefault
    } 
 
    @After 
    public void tearDown() throws Exception 
    { 
        TimeZone.setDefault(defaultTimeZone);
    } 
 
    @Test 
    public void testGetStartTimeAsDate() 
    { 
        final Date result = DateUtil.parseDateTime(dateString);
        assertEquals(1148039688000L, result.getTime());
        assertEquals("Fri May 19 11:54:48 GMT 2006", result.toString());
    } 
 
    @Test 
    public void testGetStartTimeAsDateWithTimeZone() 
    { 
        final TimeZone tz = TimeZone.getTimeZone("GMT+2");
6
CodeRank
This code example shows how to use the following methods:setDefault
    } 
 
    @Before 
    public void tearDown() 
    { 
        TimeZone.setDefault(defaultTimeZone);
    } 
 
    @Test 
    public void testGetStartTimeAsDate() 
    { 
        assertEquals(1148039688000L, cdrEvent.getStartTimeAsDate().getTime());
    } 
 
    @Test 
    public void testGetStartTimeAsDateWithTimeZone() 
    { 
        TimeZone tz = TimeZone.getTimeZone("GMT+2");
        assertEquals(1148032488000L, cdrEvent.getStartTimeAsDate(tz).getTime());
    } 
6
CodeRank
This code example shows how to use the following methods:setDefault
    @Before 
    public void setUp() throws Exception 
    { 
        this.response = new CoreStatusResponse();
        defaultTimeZone = TimeZone.getDefault();
        TimeZone.setDefault(tz);
    } 
 
    @After 
    public void tearDown() throws Exception 
    { 
        TimeZone.setDefault(defaultTimeZone);
    } 
 
    @Test 
    public void testGetCoreStartupTimeAsDate() 
    { 
        assertNotNull("TimeZone not found", tz);
        response.setCoreStartupDate("2009-05-27");
        response.setCoreStartupTime("02:49:15");
6
CodeRank
This code example shows how to use the following methods:setDefault
    TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
  } 
 
  @After 
  public void tearDown() throws Exception {
    TimeZone.setDefault(originalDefault);
  } 
 
  @Test public void parseStandardFormats() throws Exception {
    // RFC 822, updated by RFC 1123 with GMT. 
    assertEquals(0L, HttpDate.parse("Thu, 01 Jan 1970 00:00:00 GMT").getTime()); 
    assertEquals(1402057830000L, HttpDate.parse("Fri, 06 Jun 2014 12:30:30 GMT").getTime()); 
 
    // RFC 850, obsoleted by RFC 1036 with GMT. 
    assertEquals(0L, HttpDate.parse("Thursday, 01-Jan-70 00:00:00 GMT").getTime()); 
    assertEquals(1402057830000L, HttpDate.parse("Friday, 06-Jun-14 12:30:30 GMT").getTime()); 
 
    // ANSI C's asctime(): should use GMT, not platform default. 
    assertEquals(0L, HttpDate.parse("Thu Jan 1 00:00:00 1970").getTime()); 
    assertEquals(1402057830000L, HttpDate.parse("Fri Jun 6 12:30:30 2014").getTime()); 
6
CodeRank
This code example shows how to use the following methods:setDefault
            jos = new JarOutputStream(new FileOutputStream(outFile));
            System.out.println("Using timezone: " + TimeZone.getDefault());
            Utils.unpackj(packFile, jos);
        } finally { 
            Utils.close(jos);
            TimeZone.setDefault(tz); // always reset
        } 
    } 
 
    static void verifyJar(File f1, File f2) throws IOException {
        int errors = 0;
        JarFile jf1 = null;
        JarFile jf2 = null;
        try { 
            jf1 = new JarFile(f1);
            jf2 = new JarFile(f2);
            System.out.println("Verifying: " + f1 + " and " + f2);
            for (JarEntry je1 : Collections.list(jf1.entries())) {
                JarEntry je2 = jf2.getJarEntry(je1.getName());
                if (je1.getTime() != je2.getTime()) {
5
CodeRank
This code example shows how to use the following methods:setDefault
 
    public static void initialize() { 
        new TestClock(); 
 
        Locale.setDefault(Locale.UK);
        TimeZone.setDefault(timeZone);
    } 
 
    private TestClock() { 
        super(); 
    } 
 
    static { 
        timeZone = TimeZone.getTimeZone("Etc/UTC");
    } 
 
    /** 
     * Always return the time as 2003/8/17 21:30:25 
     */ 
    @Override 
5
CodeRank
This code example shows how to use the following methods:setDefault
 
    public static void initialize() { 
        new TestClock(); 
 
        Locale.setDefault(Locale.UK);
        TimeZone.setDefault(timeZone);
    } 
 
    private TestClock() { 
        super(); 
    } 
 
    static { 
        timeZone = TimeZone.getTimeZone("Etc/UTC");
    } 
 
    /** 
     * Always return the time as 2003/8/17 21:30:25 
     */ 
    @Override 
5
CodeRank
This code example shows how to use the following methods:setDefault
    } 
 
    protected void tearDown() throws Exception { 
        DateTimeUtils.setCurrentMillisSystem(); 
        DateTimeZone.setDefault(originalDateTimeZone);
        TimeZone.setDefault(originalTimeZone);
        Locale.setDefault(originalLocale);
        originalDateTimeZone = null;
        originalTimeZone = null;
        originalLocale = null;
    } 
 
    //----------------------------------------------------------------------- 
    public void testFactoryUTC() { 
        assertEquals(DateTimeZone.UTC, GJChronology.getInstanceUTC().getZone());
        assertSame(GJChronology.class, GJChronology.getInstanceUTC().getClass());
    } 
 
    public void testFactory() { 
        assertEquals(LONDON, GJChronology.getInstance().getZone());
3
CodeRank
This code example shows how to use the following methods:setDefault
    /** 
     * Format and return the given {@link Blocks} values using 
     * {@link #CONFERENCE_TIME_ZONE}. 
     */ 
    public static String formatTimeString(long time, Context context) {
        TimeZone.setDefault(CONFERENCE_TIME_ZONE);
 
        // NOTE: There is an efficient version of formatDateRange in Eclair and 
        // beyond that allows you to recycle a StringBuilder. 
        return DateUtils.formatDateTime(context, time, TIME_FLAGS);
    } 
 
    public static boolean isSameDay(long time1, long time2) {
        TimeZone.setDefault(CONFERENCE_TIME_ZONE);
 
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTimeInMillis(time1);
        cal2.setTimeInMillis(time2);
        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
3
CodeRank
This code example shows how to use the following methods:setDefault
    /** 
     * Format and return the given {@link Blocks} values using 
     * {@link #CONFERENCE_TIME_ZONE}. 
     */ 
    public static String formatBlockTimeString(long blockStart, long blockEnd, Context context) {
        TimeZone.setDefault(CONFERENCE_TIME_ZONE);
 
        // NOTE: There is an efficient version of formatDateRange in Eclair and 
        // beyond that allows you to recycle a StringBuilder. 
        return DateUtils.formatDateRange(context, blockStart, blockEnd, TIME_FLAGS);
    } 
 
    public static boolean isSameDay(long time1, long time2) {
        TimeZone.setDefault(CONFERENCE_TIME_ZONE);
 
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTimeInMillis(time1);
        cal2.setTimeInMillis(time2);
        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
3
CodeRank

Related TimeZone setDefault Questions & Answers:

setDefault Method Overview
Sets the TimeZone that is returned by the getDefault method.
See Code Examples for other Java 8 TimeZone Methods: