Java Code Examples for java.util.Calendar#getMinimalDaysInFirstWeek()

The following examples show how to use java.util.Calendar#getMinimalDaysInFirstWeek() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 2
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 3
Source Project: jdk8u60   File: Bug4518811.java    License: GNU General Public License v2.0 5 votes vote down vote up
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 4
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 5
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 6
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 7
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 8
Source Project: hottub   File: Bug4518811.java    License: GNU General Public License v2.0 5 votes vote down vote up
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 9
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 10
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 11
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 12
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 13
static int getDays(String lang, String loc){
    int errors=0;
    Locale newlocale = new Locale(lang, loc);

    Calendar newCal = Calendar.getInstance(newlocale);

    int minDays = newCal.getMinimalDaysInFirstWeek();
    System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);

    if (minDays != 4){
        System.out.println("Warning! Should be 4, not " + minDays +"!");
        errors++;
    }
    return errors;
}
 
Example 14
Source Project: olat   File: MysqlWeekHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static int getMysqlWeekMode(final Locale locale) {
    /*
     * From http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week Mode First day of week Range Week 1 is the first week … 0 Sunday 0-53
     * with a Sunday in this year 1 Monday 0-53 with more than 3 days this year 2 Sunday 1-53 with a Sunday in this year 3 Monday 1-53 with more than 3 days this year
     * 4 Sunday 0-53 with more than 3 days this year 5 Monday 0-53 with a Monday in this year 6 Sunday 1-53 with more than 3 days this year 7 Monday 1-53 with a
     * Monday in this year
     */

    final Calendar c = Calendar.getInstance(locale);
    final int firstDayOfWeek = c.getFirstDayOfWeek();
    final int minimalDaysInFirstWeek = c.getMinimalDaysInFirstWeek();

    if (firstDayOfWeek == Calendar.SUNDAY) {
        // that could be mode 0,2,4,6

        // Mode First day of week Range Week 1 is the first week …
        // 0 Sunday 0-53 with a Sunday in this year
        // 4 Sunday 0-53 with more than 3 days this year

        // 2 Sunday 1-53 with a Sunday in this year
        // 6 Sunday 1-53 with more than 3 days this year

        if (minimalDaysInFirstWeek == 7) {
            return 2;
        } else if (minimalDaysInFirstWeek > 3) {
            return 6;
        } else {
            return 4;
        }
    } else {
        // otherwise it must be MONDAY

        // that could be mode 1,3,5,7

        // Mode First day of week Range Week 1 is the first week …
        // 1 Monday 0-53 with more than 3 days this year
        // 3 Monday 1-53 with more than 3 days this year
        // 5 Monday 0-53 with a Monday in this year
        // 7 Monday 1-53 with a Monday in this year

        if (minimalDaysInFirstWeek == 7) {
            return 7;
        } else if (minimalDaysInFirstWeek > 3) {
            return 3;
        } else {
            return 1;
        }
    }
}
 
Example 15
Source Project: olat   File: MysqlWeekHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static int getMysqlWeekMode(final Locale locale) {
    /*
     * From http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week Mode First day of week Range Week 1 is the first week … 0 Sunday 0-53
     * with a Sunday in this year 1 Monday 0-53 with more than 3 days this year 2 Sunday 1-53 with a Sunday in this year 3 Monday 1-53 with more than 3 days this year
     * 4 Sunday 0-53 with more than 3 days this year 5 Monday 0-53 with a Monday in this year 6 Sunday 1-53 with more than 3 days this year 7 Monday 1-53 with a
     * Monday in this year
     */

    final Calendar c = Calendar.getInstance(locale);
    final int firstDayOfWeek = c.getFirstDayOfWeek();
    final int minimalDaysInFirstWeek = c.getMinimalDaysInFirstWeek();

    if (firstDayOfWeek == Calendar.SUNDAY) {
        // that could be mode 0,2,4,6

        // Mode First day of week Range Week 1 is the first week …
        // 0 Sunday 0-53 with a Sunday in this year
        // 4 Sunday 0-53 with more than 3 days this year

        // 2 Sunday 1-53 with a Sunday in this year
        // 6 Sunday 1-53 with more than 3 days this year

        if (minimalDaysInFirstWeek == 7) {
            return 2;
        } else if (minimalDaysInFirstWeek > 3) {
            return 6;
        } else {
            return 4;
        }
    } else {
        // otherwise it must be MONDAY

        // that could be mode 1,3,5,7

        // Mode First day of week Range Week 1 is the first week …
        // 1 Monday 0-53 with more than 3 days this year
        // 3 Monday 1-53 with more than 3 days this year
        // 5 Monday 0-53 with a Monday in this year
        // 7 Monday 1-53 with a Monday in this year

        if (minimalDaysInFirstWeek == 7) {
            return 7;
        } else if (minimalDaysInFirstWeek > 3) {
            return 3;
        } else {
            return 1;
        }
    }
}