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

The following examples show how to use java.util.Calendar#getMinimalDaysInFirstWeek() . 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 check out the related API usage on the sidebar.
Example 1
Source File: Bug4518811.java    From dragonwell8_jdk with 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 2
Source File: Bug4518811.java    From TencentKona-8 with 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 3
Source File: Bug4518811.java    From jdk8u60 with 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
Source File: Bug4518811.java    From openjdk-jdk8u with 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 5
Source File: Bug4518811.java    From openjdk-jdk8u-backup with 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 6
Source File: Bug4518811.java    From openjdk-jdk9 with 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 7
Source File: Bug4518811.java    From jdk8u-jdk with 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 8
Source File: Bug4518811.java    From hottub with 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
Source File: Bug4518811.java    From openjdk-8-source with 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 10
Source File: Bug4518811.java    From openjdk-8 with 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 11
Source File: Bug4518811.java    From jdk8u_jdk with 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 12
Source File: Bug4518811.java    From jdk8u-jdk with 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 13
Source File: Bug4518811.java    From jdk8u-dev-jdk with 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 14
Source File: MysqlWeekHelper.java    From olat with 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 File: MysqlWeekHelper.java    From olat with 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;
        }
    }
}