Java Calendar Create createIsoCalendar()

Here you can find the source of createIsoCalendar()

Description

The ISO week-numbering year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year (hence without overlap or gap).

License

Open Source License

Declaration

private static Calendar createIsoCalendar() 

Method Source Code

//package com.java2s;
/*/*from w w w .  ja v a2s .  c  o  m*/
 * DomUI Java User Interface - shared code
 * Copyright (c) 2010 by Frits Jalvingh, Itris B.V.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * See the "sponsors" file for a list of supporters.
 *
 * The latest version of DomUI and related code, support and documentation
 * can be found at http://www.domui.org/
 * The contact for the project is Frits Jalvingh <jal@etc.to>.
 */

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    /**
     * The ISO week-numbering year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year
     * (hence without overlap or gap). It consists of 52 or 53 full weeks. If 1 January is on a Monday, Tuesday, Wednesday
     * or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous
     * year (there is no week 00). 28 December is always in the last week of its year.
     *
     * @return
     */
    private static Calendar createIsoCalendar() {
        Calendar cal = new GregorianCalendar();
        cal.clear();
        cal.setMinimalDaysInFirstWeek(4);
        cal.setFirstDayOfWeek(2);
        return cal;
    }
}

Related

  1. createCalendarInstance(final Locale locale)
  2. createCalendarMidnight(final Date date)
  3. createCalendarWith()
  4. createDateFormatString(Calendar cal)
  5. createDateStr(Calendar calendar)
  6. createResetCalendar()
  7. createTimestampStr(Calendar para_calendar)
  8. getCalendar()
  9. getCalendar()