Java Day of Week getDayOfWeek(String f)

Here you can find the source of getDayOfWeek(String f)

Description

get Day Of Week

License

Apache License

Declaration

public static Integer getDayOfWeek(String f) 

Method Source Code


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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Integer getDayOfWeek(String f) {
        Integer dayOfWeek;// w  w w  .jav  a2  s.c o m

        try {
            SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
            Date dt1 = format1.parse(f);
            DateFormat format2 = new SimpleDateFormat("u");
            dayOfWeek = Integer.valueOf(format2.format(dt1));
        } catch (Exception ex) {
            dayOfWeek = new Integer(-1);
        }

        return dayOfWeek;
    }
}

Related

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