Android Calendar Get getCurrentWeek()

Here you can find the source of getCurrentWeek()

Description

get Current Week

Declaration

public static int getCurrentWeek() 

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 ww  .j a  v a2s  . c om*/

    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_UTCMilliSeconds()
  2. GetCurrentTime_UTCSeconds()
  3. getCurrentMonth()
  4. getCurrentTimeStr()
  5. getCurrentWeek()
  6. getCurrentWeek(Calendar cal)
  7. getDate()
  8. getDate()
  9. getDate(Calendar c)