Java Week getWeekId(String date)

Here you can find the source of getWeekId(String date)

Description

get Week Id

License

Open Source License

Declaration

public static Integer getWeekId(String date) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");

    public static Integer getWeekId(String date) {
        Date d = new Date();
        try {/*from  w  ww . jav a 2 s  . c o  m*/
            d = yyyyMMdd.parse(date);
        } catch (ParseException e) {
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(d);
        Integer i = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        return i;
    }
}

Related

  1. getWeekAgo()
  2. getWeekBegin(Date date)
  3. getWeekDates(int weekOffset)
  4. getWeekFirst(String format)
  5. getWeekFromDate(String dateString)
  6. getWeekInMonth()
  7. getWeekName()
  8. getWeekNumber(String sdate)
  9. getWeekNumberFromDate(String thedate)