Android Calendar Get getCurrentWeek(Calendar cal)

Here you can find the source of getCurrentWeek(Calendar cal)

Description

get Current Week

Declaration

public static int getCurrentWeek(Calendar cal) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    public static int getCurrentWeek() {
        Calendar cal = Calendar.getInstance();
        return cal.get(Calendar.WEEK_OF_YEAR);
    }//  w w w  .  j a va2s .  c o  m

    public static int getCurrentWeek(Calendar cal) {
        if (cal == null) {
            cal = Calendar.getInstance();
        }
        return cal.get(Calendar.WEEK_OF_YEAR);
    }

    public static int getCurrentWeek(Timestamp t1) {
        Calendar cal;
        if (t1 == null) {
            cal = Calendar.getInstance();
        } else {
            cal = new GregorianCalendar();
            cal.setTime(t1);
        }
        return cal.get(Calendar.WEEK_OF_YEAR);
    }
}

Related

  1. GetCurrentTime_UTCSeconds()
  2. getCurrentMonth()
  3. getCurrentTimeStr()
  4. getCurrentWeek()
  5. getCurrentWeek()
  6. getDate()
  7. getDate()
  8. getDate(Calendar c)
  9. getDateAsDirName()