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
 
 
    private GregorianCalendar parse(String o1, DateFormat formatter) {
        try { 
            Date date = formatter.parse(o1);
            GregorianCalendar c = new GregorianCalendar();
            c.setTime(date);
            return c;
        } catch (java.text.ParseException e) {
            return null; 
        } 
    } 
 
 
    @Override 
    public void write(JSONWriter writer, Properties options)
    throws JSONException { 
 
        writer.object();
        writer.key("description"); writer.value("Returns o converted to a date object, you can hint if the day or the month is listed first, or give an ordered list of possible formats using this syntax: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html");
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setTime
        // current "nextExpiration" 
        Date currentTimeout = timer.getNextExpiration();
        if (currentTimeout == null) {
            return null; 
        } 
        Calendar cal = new GregorianCalendar();
        cal.setTime(currentTimeout);
        // now compute the next timeout date 
        Calendar nextTimeout = ((CalendarTimer) timer).getCalendarTimeout().getNextTimeout(cal);
        if (nextTimeout != null) {
            return nextTimeout.getTime();
        } 
        return null; 
    } 
 
    @Override 
    protected void scheduleTimeoutIfRequired(TimerImpl timer) {
        if (timer.getNextExpiration() != null) {
            timer.scheduleTimeout(false);
        } 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getActualMaximum, set
     * @param calendar The {@link java.util.Calendar} whose {@link java.util.Calendar#MONTH} field will be used 
     *                 as the current month 
     * @return 
     */ 
    public static int getLastDateOfMonth(Calendar calendar) {
        Calendar tmpCal = new GregorianCalendar(calendar.getTimeZone());
        tmpCal.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        tmpCal.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        tmpCal.set(Calendar.DAY_OF_MONTH, 1);
        return tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH);
    } 
 
    public static Integer getNthDayOfMonth(Calendar cal, int n, int dayOfWeek) {
        int dateOfFirstXXXDay = getFirstDateInMonthForDayOfWeek(cal, dayOfWeek);
 
        final int FIRST_WEEK = 1;
        final int NUM_DAYS_IN_WEEK = 7;
 
        int weekDiff = n - FIRST_WEEK;
 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: clear, get, set
    } 
 
    private void testSetSelfConsistent(TimeZone timeZone, int year, int month, int day) {
        int hour = 0;
        int minute = 0;
        Calendar calendar = new GregorianCalendar(timeZone);
        calendar.clear();
        calendar.set(year, month, day, hour, minute);
        assertEquals(year, calendar.get(Calendar.YEAR));
        assertEquals(month, calendar.get(Calendar.MONTH));
        assertEquals(day, calendar.get(Calendar.DAY_OF_MONTH));
        assertEquals(hour, calendar.get(Calendar.HOUR_OF_DAY));
        assertEquals(minute, calendar.get(Calendar.MINUTE));
    } 
 
    // http://b/5179775 
    public void testCalendarSerialization() { 
        String s = "aced00057372001b6a6176612e7574696c2e477265676f7269616e43616c656e6461728f3dd7d6e"
                + "5b0d0c103000749000f63757272656e7459656172536b65774a0010677265676f7269616e4375746" 
                + "f7665725a000869734361636865644a00126c6173744d69646e696768744d696c6c697349000c6c6" 
Full Snippet Info
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: 
Full Snippet Info
8
CodeRank
Related Java 8 GregorianCalendar Questions & Answers:
See Code Examples for Java 8 GregorianCalendar Methods: