Java Calendar Year getWeekOfYearYear(GregorianCalendar cal)

Here you can find the source of getWeekOfYearYear(GregorianCalendar cal)

Description

get Week Of Year Year

License

Open Source License

Declaration

public static int getWeekOfYearYear(GregorianCalendar cal) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    public static int getWeekOfYearYear(GregorianCalendar cal) {
        int y = cal.get(Calendar.YEAR);
        int m = cal.get(Calendar.MONTH) + 1 - Calendar.JANUARY;
        int w = cal.get(Calendar.WEEK_OF_YEAR);

        if (w == 1 && m == 12)
            return y + 1;

        if (w > 50 && m == 1)
            return y - 1;

        return y;
    }/*from   w  w  w. ja  v a 2  s  .  c om*/
}

Related

  1. getLastYear(Calendar cal)
  2. getStartOfWeekCalendar(final int year, final int weekOfYear, final Locale locale)
  3. getValidCalendar(int year, int month, int day)
  4. getWeekOfYear(Calendar currentDate)
  5. getWeekOfYear(int startDay, Calendar dt)
  6. getYear(Calendar cal)
  7. getYear(Calendar calendar)
  8. getYear(Calendar calendar)
  9. getYear(Calendar calendar)