Best code examples for Java 8 GregorianCalendar class (java.util.GregorianCalendar)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 GregorianCalendar class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 GregorianCalendar examples from Open Source projects
This code example shows how to use the following methods: setTime
167:	GregorianCalendar c = new GregorianCalendar(); 
168:	c.setTime(date); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setTime
75:	Calendar cal = new GregorianCalendar(); 
76:	cal.setTime(currentTimeout); 
-
78:	Calendar nextTimeout = ((CalendarTimer) timer).getCalendarTimeout().getNextTimeout(cal); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getActualMaximum, set
44:	Calendar tmpCal = new GregorianCalendar(calendar.getTimeZone()); 
45:	tmpCal.set(Calendar.YEAR, calendar.get(Calendar.YEAR)); 
46:	tmpCal.set(Calendar.MONTH, calendar.get(Calendar.MONTH)); 
47:	tmpCal.set(Calendar.DAY_OF_MONTH, 1); 
48:	return tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: clear, get, set
149:	Calendar calendar = new GregorianCalendar(timeZone); 
150:	calendar.clear(); 
151:	calendar.set(year, month, day, hour, minute); 
152:	assertEquals(year, calendar.get(Calendar.YEAR)); 
153:	assertEquals(month, calendar.get(Calendar.MONTH)); 
154:	assertEquals(day, calendar.get(Calendar.DAY_OF_MONTH)); 
155:	assertEquals(hour, calendar.get(Calendar.HOUR_OF_DAY)); 
156:	assertEquals(minute, calendar.get(Calendar.MINUTE)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: get, setTime, setTimeZone
68:	GregorianCalendar calendar = new GregorianCalendar(); 
69:	calendar.setTimeZone(defaultFormatTimeZone()); 
70:	calendar.setTime(timestamp); 
71:	switch (calendar.get(GregorianCalendar.DAY_OF_MONTH)) { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: get
19:	assertThat(dateRetrieved.get(GregorianCalendar.YEAR)) 
-
22:	assertThat(dateRetrieved.get(GregorianCalendar.MONTH)) 
-
25:	assertThat(dateRetrieved.get(GregorianCalendar.DAY_OF_MONTH)) 
-
28:	assertThat(dateRetrieved.get(GregorianCalendar.HOUR_OF_DAY)) 
-
31:	assertThat(dateRetrieved.get(GregorianCalendar.MINUTE)) 
-
34:	assertThat(dateRetrieved.get(GregorianCalendar.SECOND)) 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: get, getTime, set, setTime, add
45:	gc.setTime(startDate); 
-
48:	if (gc.get(Calendar.DAY_OF_WEEK) > meetingDayOfWeek) { 
49:	gc.add(Calendar.WEEK_OF_MONTH, 1); 
-
53:	gc.set(Calendar.DAY_OF_WEEK, meetingDayOfWeek); 
54:	return gc.getTime(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: get
41:	GregorianCalendar currentCalendar = new GregorianCalendar(); 
-
43:	currentCalendar.get(Calendar.YEAR), 
44:	currentCalendar.get(Calendar.MONTH), 
45:	currentCalendar.get(Calendar.DAY_OF_MONTH), 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
198:	Calendar calendar = new GregorianCalendar(); 
-
201:	milliseconds += calendar.get(Calendar.ZONE_OFFSET); 
-
204:	calendar.setTime(new Date(milliseconds)); 
205:	milliseconds += calendar.get(Calendar.DST_OFFSET); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: set
65:	Calendar today = new GregorianCalendar(); 
66:	today.set(GregorianCalendar.HOUR_OF_DAY, 0); 
67:	today.set(GregorianCalendar.MINUTE, 0); 
68:	today.set(GregorianCalendar.SECOND, 0); 
69:	today.set(GregorianCalendar.MILLISECOND, 0); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setTimeInMillis
29:	Calendar cal = new GregorianCalendar(); 
30:	cal.setTimeInMillis(file.lastModified()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: set
43:	Calendar calender = new GregorianCalendar(); 
44:	calender.set(year, month, day, hrs, min, sec); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setFirstDayOfWeek, setMinimalDaysInFirstWeek, setTimeZone
187:	Calendar calendar = new GregorianCalendar(1970, 1, 1, 0, 0, 0); 
188:	calendar.setTimeZone(TimeZone.getTimeZone("GMT-08:00")); 
189:	calendar.setFirstDayOfWeek(1); 
190:	calendar.setMinimalDaysInFirstWeek(4); 
191:	new SerializableTester<Calendar>(calendar, s).test(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: get, getTime, setTime, add
61:	final GregorianCalendar firstDateForWeek = new GregorianCalendar(); 
62:	firstDateForWeek.setTime(startDate.toDate()); 
-
64:	int startDateWeekDay = firstDateForWeek.get(Calendar.DAY_OF_WEEK); 
-
69:	firstDateForWeek.add(Calendar.DAY_OF_WEEK, amountOfDaysToAdd); 
70:	return new DateTime(firstDateForWeek.getTime()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setFirstDayOfWeek, setMinimalDaysInFirstWeek
369:	Calendar cal = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3, 6); 
370:	cal.setMinimalDaysInFirstWeek(1); 
371:	cal.setFirstDayOfWeek(1); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: before, get
97:	GregorianCalendar preferredDate = new GregorianCalendar(year, monthOfYear, dayOfMonth); 
-
101:	if (preferredDate.before(oldestDate)) { // is the birthdate before 1916 (android.DateUtils) 
-
105:	oldestDate.set(Calendar.MONTH, preferredDate.get(Calendar.MONTH)); 
106:	oldestDate.set(Calendar.DAY_OF_MONTH, preferredDate.get(Calendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime
41:	Calendar then=new GregorianCalendar(year, monthOfYear, dayOfMonth); 
-
43:	Toast.makeText(this, then.getTime().toString(), Toast.LENGTH_LONG) 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, set
127:	Calendar today = new GregorianCalendar(); 
128:	today.set(Calendar.HOUR_OF_DAY, 0); 
129:	today.set(Calendar.MINUTE, 0); 
130:	today.set(Calendar.SECOND, 0); 
131:	today.set(Calendar.MILLISECOND, 0); 
132:	return today.getTime(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, setTime, add
64:	GregorianCalendar calendar = new GregorianCalendar(); 
65:	calendar.setTime(Clock.currentDate()); 
-
69:	.format(calendar.getTime()); 
-
73:	calendar.add(incrementUnit, increment); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
104:	final GregorianCalendar gc = new GregorianCalendar(); 
105:	gc.setTime((Date) o); 
106:	final int year = gc.get(Calendar.YEAR); 
107:	final int month = gc.get(Calendar.MONTH); 
108:	final int day = gc.get(Calendar.DAY_OF_MONTH); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setTime
243:	GregorianCalendar c = new GregorianCalendar(); 
244:	c.setTime(source); 
-
246:	return factory.newXMLGregorianCalendar(c); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
34:	GregorianCalendar calendar = new GregorianCalendar(); 
-
36:	calendar.setTime(hireDay); 
37:	out.println(name+"|"+salary+"|"+calendar.get(Calendar.YEAR)+"|"+ 
38:	(calendar.get(Calendar.MONTH)+1)+"|"+calendar.get(Calendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setTime
186:	Calendar calendar = new GregorianCalendar(AMERICA_LOS_ANGELES); 
187:	calendar.setTime(format.parse("2011-06-21T10:00 Pacific Standard Time")); // 18:00 GMT-8 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, setTime, add
76:	GregorianCalendar calendar = new GregorianCalendar(); 
77:	calendar.setTime(startDate); 
78:	calendar.add(unit, quantity); 
-
80:	return calendar.getTime(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
52:	GregorianCalendar ddate = new GregorianCalendar(); 
53:	ddate.setTime(d); 
54:	GregorianCalendar ddateday = new GregorianCalendar(ddate.get(GregorianCalendar.YEAR), ddate.get(GregorianCalendar.MONTH), ddate.get(GregorianCalendar.DAY_OF_MONTH) 
55:	, ddate.get(GregorianCalendar.HOUR_OF_DAY), ddate.get(GregorianCalendar.MINUTE)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTimeInMillis
216:	GregorianCalendar gregorianCalendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 
217:	gregorianCalendar.setTimeInMillis(timeUtc); 
218:	int hour = gregorianCalendar.get(Calendar.HOUR_OF_DAY); 
219:	int min = gregorianCalendar.get(Calendar.MINUTE); 
220:	int sec = gregorianCalendar.get(Calendar.SECOND); 
221:	int millis = gregorianCalendar.get(Calendar.MILLISECOND); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, getTime, set, setTimeInMillis
167:	final GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 
168:	calendar.setTimeInMillis(date.getTime()); // We must not use setTime(date) in case the date is not UTC. 
169:	calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0); 
170:	calendar.set(Calendar.MILLISECOND, 0); 
171:	return calendar.getTime(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: set, setTime
153:	final GregorianCalendar gc = new GregorianCalendar(context.getTimeZone(), 
-
155:	gc.setTime(ISO8001_TIME); 
156:	gc.set(Calendar.MILLISECOND, 0); 
157:	gc.set(Calendar.HOUR_OF_DAY, hour); 
158:	gc.set(Calendar.MINUTE, minute); 
159:	gc.set(Calendar.SECOND, second); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime
64:	Calendar then=new GregorianCalendar(year, monthOfYear, dayOfMonth); 
-
66:	Toast.makeText(this, then.getTime().toString(), Toast.LENGTH_LONG) 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, getTime, set, add
83:	final GregorianCalendar gc = new GregorianCalendar(context.getTimeZone(), 
-
85:	gc.set(Calendar.MILLISECOND, 0); 
86:	final int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK); 
-
91:	gc.add(Calendar.DAY_OF_MONTH, -2); 
-
95:	gc.add(Calendar.DAY_OF_MONTH, -3); 
-
99:	gc.add(Calendar.DAY_OF_MONTH, -1); 
-
106:	gc.add(Calendar.DAY_OF_MONTH, -2); 
-
110:	gc.add(Calendar.DAY_OF_MONTH, -3); 
-
114:	gc.add(Calendar.DAY_OF_MONTH, -1); 
-
118:	return gc.getTime(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get
11:	int year = glc.get(GregorianCalendar.YEAR); 
12:	int month = glc.get(GregorianCalendar.MONTH) + 1; 
-
14:	x = glc.get(GregorianCalendar.DATE); 
15:	int hour = glc.get(GregorianCalendar.HOUR_OF_DAY); 
16:	int minute = glc.get(GregorianCalendar.MINUTE); 
17:	int second = glc.get(GregorianCalendar.SECOND); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, setTimeZone
49:	GregorianCalendar c = new GregorianCalendar(2006, 0, 9, 19, 20, 11); 
50:	c.setTimeZone(TimeZone.getTimeZone("UTC")); 
51:	assertEquals(c.getTime(), item.getDate()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
34:	GregorianCalendar calendar = new GregorianCalendar(); 
-
36:	calendar.setTime(hireDay); 
37:	out.println(name+"|"+salary+"|"+calendar.get(Calendar.YEAR)+"|"+ 
38:	(calendar.get(Calendar.MONTH)+1)+"|"+calendar.get(Calendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, set, setTime, add
59:	final GregorianCalendar gc = new GregorianCalendar(localizationContext.getTimeZone(), 
-
61:	gc.setTime(context.getCurrentDate()); 
62:	gc.set(Calendar.MILLISECOND, 0); 
63:	gc.add(Calendar.DAY_OF_MONTH, -1); 
64:	return gc.getTime(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
50:	GregorianCalendar g2 = new GregorianCalendar(); 
51:	g2.setTime(new Date()); 
-
53:	if(g1.get(Calendar.YEAR)==g2.get(Calendar.YEAR) && g1.get(Calendar.MONTH)==g2.get(Calendar.MONTH) && g1.get(Calendar.DAY_OF_MONTH)==g2.get(Calendar.DAY_OF_MONTH)) 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get
33:	sRet = String.valueOf(c.get(Calendar.YEAR)); 
34:	sRet = sRet + "-" +String.valueOf(c.get(Calendar.MONTH)+1); 
35:	sRet = sRet + "-" +String.valueOf(c.get(Calendar.DAY_OF_MONTH)); 
-
37:	sRet = sRet + " " +String.valueOf(c.get(Calendar.HOUR_OF_DAY)); 
38:	sRet = sRet + ":" +String.valueOf(c.get(Calendar.MINUTE)); 
39:	sRet = sRet + ":" +String.valueOf(c.get(Calendar.SECOND)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
37:	GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 
38:	cal.setTime((Date) f.getAttribute("date")); 
39:	assertEquals(1980, cal.get(GregorianCalendar.YEAR)); 
40:	assertEquals(9, cal.get(GregorianCalendar.MONTH) + 1); // 0-based month! 
41:	assertEquals(10, cal.get(GregorianCalendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTime, set
26:	GregorianCalendar referenceDate = new GregorianCalendar(); 
27:	referenceDate.set(2001, 0, 0, 0, 0, 0); 
28:	return timeIntervalSinceDate(referenceDate.getTime()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getActualMaximum, set
720:	Calendar tmpCal = new GregorianCalendar(cal.getTimeZone()); 
721:	tmpCal.set(Calendar.YEAR, cal.get(Calendar.YEAR)); 
722:	tmpCal.set(Calendar.MONTH, cal.get(Calendar.MONTH)); 
723:	tmpCal.set(Calendar.DAY_OF_MONTH, 1); 
724:	int maximumPossibleDateForTheMonth = tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: clear, getTimeInMillis, set
99:	final GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 
100:	utc.clear(); 
101:	utc.set(year, month, dayOfMonth, 0, 0, 0); 
102:	utc.set(Calendar.MILLISECOND, 0); 
-
104:	return (long) (utc.getTimeInMillis() / millisPerDay - epochJulianDate); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
91:	GregorianCalendar calendar = new GregorianCalendar(); 
92:	calendar.setTime(hireDay); 
93:	out.println(name + "|" + salary + "|" + calendar.get(Calendar.YEAR) 
94:	+ "|" + (calendar.get(Calendar.MONTH) + 1) + "|" + calendar.get(Calendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get, setTime
84:	GregorianCalendar calendar = new GregorianCalendar(); 
85:	calendar.setTime(hireDay); 
86:	out.writeInt(calendar.get(Calendar.YEAR)); 
87:	out.writeInt(calendar.get(Calendar.MONTH) + 1); 
88:	out.writeInt(calendar.get(Calendar.DAY_OF_MONTH)); 
Full Snippet Info
7
CodeRank
Related Java 8 GregorianCalendar Questions & Answers:
See Code Examples for Java 8 GregorianCalendar Methods: