Java Day of Week dayForWeek(String pTime)

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

Description

day For Week

License

Apache License

Declaration


public static int dayForWeek(String pTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {

    public static int dayForWeek(String pTime) {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        Calendar c = Calendar.getInstance();
        int dayForWeek = 0;
        try {/* w ww  .j a  v a 2 s .c  o  m*/
            c.setTime(format.parse(pTime));
            if (c.get(Calendar.DAY_OF_WEEK) == 1) {
                dayForWeek = 7;
            } else {
                dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dayForWeek;
    }
}

Related

  1. calculateBusinessDays(Date startDate, Date endDate, int firstWeekendDay, int secondWeekendDay)
  2. Day_Of_Week(String Date, int DayCase)
  3. dayForWeek(String pTime)
  4. dayForWeek(String weeks)
  5. dayNumberOfWeek(Date date)
  6. DayOfTheWeek(Date dt)