Java Week Day getCurWeek(String day)

Here you can find the source of getCurWeek(String day)

Description

get Cur Week

License

Open Source License

Declaration

public static int getCurWeek(String day) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static int getCurWeek(String day) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;//from w  ww. j  ava  2s.  c o m
        if (day != null) {
            try {
                date = format.parse(day);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        } else {
            date = new Date();
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTime(date);
        return calendar.get(Calendar.WEEK_OF_YEAR);
    }
}

Related

  1. firstDayOfWeek(int year, int month)
  2. getAPastDayOfTheWeek(String dayToGet)
  3. getBothDayOfWeek(String str, int week)
  4. getCurrentDayOfWeekArabia()
  5. getCurrentDayOfWeekEnglish()
  6. getCurWeekDayByStr(String curday)
  7. getCurWeekDayByStr(String curday)
  8. getDay(long date, int startOfWeek, int increment)
  9. getDayNextWeek()