Java Day of Week getDayOfWeek(String date, String pattern)

Here you can find the source of getDayOfWeek(String date, String pattern)

Description

get Day Of Week

License

Apache License

Declaration

public static int getDayOfWeek(String date, String pattern) throws Exception 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int getDayOfWeek(String date, String pattern) throws Exception {
        Calendar c = Calendar.getInstance();
        int result = -1;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date d = sdf.parse(date);
        c.setTime(d);//from   w ww  .  jav  a  2  s .c om
        result = c.get(Calendar.DAY_OF_WEEK) - 1;
        return result;
    }
}

Related

  1. getDayOfWeek()
  2. getDayOfWeek(Date date)
  3. getDayOfWeek(int _year, int _month, int _day)
  4. getDayOfWeek(int year, int month, int day)
  5. getDayOfWeek(int year, int month, int day)
  6. getDayOfWeek(String datetime)
  7. getDayOfWeek(String f)
  8. getDayOfWeek(String format, int calendarField)
  9. getDayOfWeekAsString(String sYear, String sMonth, String sDay)