Java Week getWeek(String pTime)

Here you can find the source of getWeek(String pTime)

Description

get Week

License

Open Source License

Declaration

public static int getWeek(String pTime) throws Exception 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {

    public static int getWeek(String pTime) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.setTime(format.parse(pTime));/*from w  ww  .  java  2 s.c  o m*/
        int dayForWeek = 0;
        if (c.get(Calendar.DAY_OF_WEEK) == 1) {
            dayForWeek = 7;
        } else {
            dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
        }
        return dayForWeek;
    }
}

Related

  1. getWeek()
  2. getWeek(Date date)
  3. getWeek(int duration)
  4. getWeek(SimpleDateFormat df, String dateStr)
  5. getWeek(String date)
  6. getWeekAgo()
  7. getWeekBegin(Date date)
  8. getWeekDates(int weekOffset)
  9. getWeekFirst(String format)