Java Day of Week getWeekDay(String strDate)

Here you can find the source of getWeekDay(String strDate)

Description

get Week Day

License

Open Source License

Declaration

public static int getWeekDay(String strDate) 

Method Source Code

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

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {

    public static int getWeekDay(String strDate) {
        Calendar cal = parseDateTime(strDate);
        return cal.get(Calendar.DAY_OF_WEEK);
    }//from   w  ww  .  ja  va2s .co  m

    public static Calendar parseDateTime(String baseDate) {
        Calendar cal = null;
        cal = new GregorianCalendar();
        int yy = Integer.parseInt(baseDate.substring(0, 4));
        int mm = Integer.parseInt(baseDate.substring(5, 7)) - 1;
        int dd = Integer.parseInt(baseDate.substring(8, 10));
        int hh = 0;
        int mi = 0;
        int ss = 0;
        if (baseDate.length() > 12) {
            hh = Integer.parseInt(baseDate.substring(11, 13));
            mi = Integer.parseInt(baseDate.substring(14, 16));
            ss = Integer.parseInt(baseDate.substring(17, 19));
        }
        cal.set(yy, mm, dd, hh, mi, ss);
        return cal;
    }
}

Related

  1. getWeekDay(Date date)
  2. getWeekDay(Date date)
  3. getWeekDay(Date date)
  4. getWeekDay(Date date)
  5. getWeekDay(Date dt, int weekDay)
  6. getWeekdayDate(Date actualDate)
  7. getWeekdayInterval(Date date)
  8. getWeekDayOfYear(Date date)
  9. getWeekDays(String _date, int _amount)