Calendar setTimeZone - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:setMinimalDaysInFirstWeek, setTimeZone
                + "001000000000000000000000000fe488c00000000010000000000000001000000000000000000000" 
                + "0000000000000757200025b42acf317f8060854e002000078700000000c1f1c1f1e1f1e1f1f1e1f1" 
                + "e1f7708000000040001000178780000000afffff4e2f964ac0001000000009fa5240000000000000" 
                + "00000a4cb7c187571007e00060000000a000007b2000000010000000100000001fe488c000000000" 
                + "10000000500000001000000200000000178"; 
        Calendar calendar = new GregorianCalendar(1970, 1, 1, 0, 0, 0);
        calendar.setTimeZone(TimeZone.getTimeZone("GMT-08:00"));
        // Starting from ICU4.8 release, the default minimalDaysInFirstWeek changed from 4 to 1. 
        calendar.setMinimalDaysInFirstWeek(4);
        new SerializationTester<Calendar>(calendar, s).test();
    } 
 
    private void assertCalendarEquals(Calendar calendar,
            int year, int month, int day, int hour, int minute) {
        assertEquals(year, calendar.get(Calendar.YEAR));
        assertEquals(month, calendar.get(Calendar.MONTH));
        assertEquals(day, calendar.get(Calendar.DATE));
        assertEquals(hour, calendar.get(Calendar.HOUR_OF_DAY));
        assertEquals(minute, calendar.get(Calendar.MINUTE));
    } 
8
CodeRank
This code example shows how to use the following methods:get, setTime, setTimeZone
		} 
		return toAppendTo.append(formatted);
	} 
 
	private String ordinalSuffix(NSTimestamp timestamp) {
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.setTimeZone(defaultFormatTimeZone());
		calendar.setTime(timestamp);
		switch (calendar.get(GregorianCalendar.DAY_OF_MONTH)) {
		case 1: 
		case 21: 
		case 31: 
			return "st"; 
		case 2: 
		case 22: 
			return "nd"; 
		case 3: 
		case 23: 
			return "rd"; 
		default: 
8
CodeRank
This code example shows how to use the following methods:setFirstDayOfWeek, setMinimalDaysInFirstWeek, setTimeZone
                + "001000000000000000000000000fe488c00000000010000000000000001000000000000000000000" 
                + "0000000000000757200025b42acf317f8060854e002000078700000000c1f1c1f1e1f1e1f1f1e1f1" 
                + "e1f7708000000040001000178780000000afffff4e2f964ac0001000000009fa5240000000000000" 
                + "00000a4cb7c187571007e00060000000a000007b2000000010000000100000001fe488c000000000" 
                + "10000000500000001000000200000000178"; 
        Calendar calendar = new GregorianCalendar(1970, 1, 1, 0, 0, 0);
        calendar.setTimeZone(TimeZone.getTimeZone("GMT-08:00"));
        calendar.setFirstDayOfWeek(1);
        calendar.setMinimalDaysInFirstWeek(4);
        new SerializableTester<Calendar>(calendar, s).test();
    } 
 
    private void assertCalendarEquals(Calendar calendar,
            int year, int month, int day, int hour, int minute) {
        assertEquals(year, calendar.get(Calendar.YEAR));
        assertEquals(month, calendar.get(Calendar.MONTH));
        assertEquals(day, calendar.get(Calendar.DATE));
        assertEquals(hour, calendar.get(Calendar.HOUR_OF_DAY));
        assertEquals(minute, calendar.get(Calendar.MINUTE));
    } 
8
CodeRank
This code example shows how to use the following methods:get, getTime, setTimeZone
        buffer.append(hour).append(':').append(minute < 10 ? "0" + minute : minute);
        return buffer.toString();
    } 
 
    private double computeSolarEventTime(double solarZenith, Calendar date, boolean isSunrise) {
        date.setTimeZone(mTimeZone);
        double longitudeHour = getLongitudeHour(date, isSunrise);
        double meanAnomaly = getMeanAnomaly(longitudeHour);
        double sunTrueLong = getSunTrueLongitude(meanAnomaly);
        double cosineSunLocalHour = getCosineSunLocalHour(sunTrueLong, solarZenith);
        if ((cosineSunLocalHour < -1.0) || (cosineSunLocalHour > 1.0)) {
            return 0; 
        } 
 
        double sunLocalHour = getSunLocalHour(cosineSunLocalHour, isSunrise);
        double localMeanTime = getLocalMeanTime(sunTrueLong, longitudeHour, sunLocalHour);
        return getLocalTime(localMeanTime, date);
    } 
 
    /** 

7
CodeRank
This code example shows how to use the following methods:add, set, setTime, setTimeZone
		list.add(new Object[] { new Date(), TimeZone.getTimeZone("CET") }); 
		return list; 
	} 
 
	private void roundup(Calendar calendar) {
		calendar.add(Calendar.SECOND, 1);
		calendar.set(Calendar.MILLISECOND, 0);
	} 
 
 
	@Before 
	public void setUp() { 
		calendar.setTimeZone(timeZone);
		calendar.setTime(date);
		roundup(calendar);
	} 
 
	@Test
	public void testMatchAll() throws Exception {
		CronTrigger trigger = new CronTrigger("* * * * * *", timeZone);
7
CodeRank
This code example shows how to use the following methods:add, after, clone, set, setTime
     * @param timestampStr The timestamp to be parsed 
     * @param serverTime The current time for the server 
     * @since 1.5 
     */ 
    public Calendar parseTimestamp(String timestampStr, Calendar serverTime) throws ParseException {
        Calendar now = (Calendar) serverTime.clone();// Copy this, because we may change it
        now.setTimeZone(this.getServerTimeZone());
        Calendar working = (Calendar) now.clone();
        working.setTimeZone(getServerTimeZone()); // is this needed?
        ParsePosition pp = new ParsePosition(0);
 
        Date parsed = null;
        if (recentDateFormat != null) {
            if (lenientFutureDates) {
                // add a day to "now" so that "slop" doesn't cause a date 
                // slightly in the future to roll back a full year.  (Bug 35181 => NET-83) 
                now.add(Calendar.DATE, 1);
            } 
            parsed = recentDateFormat.parse(timestampStr, pp);
        } 

7
CodeRank
This code example shows how to use the following methods:getTime, setTimeZone
        assertNotNull(item);
        assertEquals(new Version("2.0"), item.getVersion());
        assertEquals("Version 2.0", item.getTitle());
        assertEquals("2.0 Release Notes.", item.getDescription());
        // Months start from zero. 
        GregorianCalendar c = new GregorianCalendar(2006, 0, 9, 19, 20, 11);
        c.setTimeZone(TimeZone.getTimeZone("UTC"));
        assertEquals(c.getTime(), item.getDate());
        assertTrue(item.isNewerThan(updater.getHost()));
    } 
 
    /** 
     * Test what happens if the appcast file can not be found. 
     */ 
    @Test 
    public void testNotFound() { 
        Updater updater = new Updater(new NotFoundHost());
        TestUpdateDelegate delegate = checkForUpdates(updater);
        assertFalse(delegate.checkPerformed);
        assertEquals(FileNotFoundException.class, delegate.throwable.getClass());
7
CodeRank
This code example shows how to use the following methods:add, getTime, setTime, setTimeZone
        // here... 
         
        //performance tuning 
        //Calendar calendar = Calendar.getInstance(zone); 
        Calendar calendar = mWorkCalendar;
        calendar.setTimeZone(zone);
         
        calendar.setTime(base);
        calendar.add(this.unitType.getCalendarField(), this.count);
        return calendar.getTime();
    } 
 
    /** 
     * Rolls the date forward by the amount specified by the roll unit and 
     * count. 
     * 
     * @param base  the base date. 
 
     * @return The rolled date. 
     * 
7
CodeRank
This code example shows how to use the following methods:get, getTime, setTimeZone
        buffer.append(hour).append(':').append(minute < 10 ? "0" + minute : minute);
        return buffer.toString();
    } 
 
    private double computeSolarEventTime(double solarZenith, Calendar date, boolean isSunrise) {
        date.setTimeZone(mTimeZone);
        double longitudeHour = getLongitudeHour(date, isSunrise);
        double meanAnomaly = getMeanAnomaly(longitudeHour);
        double sunTrueLong = getSunTrueLongitude(meanAnomaly);
        double cosineSunLocalHour = getCosineSunLocalHour(sunTrueLong, solarZenith);
        if ((cosineSunLocalHour < -1.0) || (cosineSunLocalHour > 1.0)) {
            return 0; 
        } 
 
        double sunLocalHour = getSunLocalHour(cosineSunLocalHour, isSunrise);
        double localMeanTime = getLocalMeanTime(sunTrueLong, longitudeHour, sunLocalHour);
        return getLocalTime(localMeanTime, date);
    } 
 
    /** 

7
CodeRank
This code example shows how to use the following methods:clear, get, setTime, setTimeZone
	 
	public static double call(PageContext pc , DateTime left, DateTime right, String datepart) throws ExpressionException {
		datepart=datepart.toLowerCase().trim();
		TimeZone tz=ThreadLocalPageContext.getTimeZone(pc);
		Calendar cLeft=JREDateTimeUtil.getThreadCalendar(tz);
		cLeft.setTime(left);
		 
		Calendar cRight=JREDateTimeUtil.newInstance(tz);
		cRight.setTime(right);
		 
		// TODO WEEEK 
		 
		int type=0;
		if(datepart.equals("s")) 		type=Calendar.SECOND;		
		else if(datepart.equals("n"))	type=Calendar.MINUTE;		
		else if(datepart.equals("h"))	type=Calendar.HOUR;		
		else if(datepart.equals("d"))	type=Calendar.DATE;	
		else if(datepart.equals("m"))	type=Calendar.MONTH;
		else if(datepart.equals("y"))	type=Calendar.DATE;
		else if(datepart.equals("yyyy"))type=Calendar.YEAR;

6
CodeRank

Related Calendar setTimeZone Questions & Answers:

setTimeZone Method Overview
Sets the time zone with the given time zone value.
See Code Examples for other Java 8 Calendar Methods: