Java Week Day getCurWeekDayByStr(String curday)

Here you can find the source of getCurWeekDayByStr(String curday)

Description

get Cur Week Day By Str

License

Apache License

Declaration

public static int getCurWeekDayByStr(String curday) 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");

    public static int getCurWeekDayByStr(String curday) {
        try {//from  w  w w.ja  v a 2s .  co  m
            java.util.Date date = str2utilDate(curday);
            Calendar rightNow = Calendar.getInstance();
            rightNow.setTime(date);
            int week = rightNow.get(Calendar.DAY_OF_WEEK);
            return week;
        } catch (Exception e) {
            System.out.println("DateUtil.getYearWeek(str) Error:e = " + e);
            return 1;
        }
    }

    public static java.util.Date str2utilDate(String str) {
        try {
            java.util.Date udate = yyyyMMdd.parse(str);
            return udate;
        } catch (Exception e) {
            System.out.println("DateUtil.str2utilDate(str) Error:e = " + e);
            return null;
        }
    }
}

Related

  1. getAPastDayOfTheWeek(String dayToGet)
  2. getBothDayOfWeek(String str, int week)
  3. getCurrentDayOfWeekArabia()
  4. getCurrentDayOfWeekEnglish()
  5. getCurWeek(String day)
  6. getCurWeekDayByStr(String curday)
  7. getDay(long date, int startOfWeek, int increment)
  8. getDayNextWeek()
  9. getDayOfTheWeekFromNow(int nDays)