Java Week Day getWeekday(String date)

Here you can find the source of getWeekday(String date)

Description

get Weekday

License

Apache License

Declaration

public static String getWeekday(String date) 

Method Source Code

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

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

import java.util.Date;

public class Main {

    public static String getWeekday(String date) {
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdw = new SimpleDateFormat("E");
        Date d = null;/*from  w  w w .j av  a  2 s .c om*/
        try {
            d = sd.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            d = new Date();
        }
        return sdw.format(d);
    }

    public static String format(Date aTs_Datetime) {
        return format(aTs_Datetime, "yyyy-MM-dd");
    }

    public static String format(Date aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;

        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }
}

Related

  1. getWeekday(Date date)
  2. getWeekDay(Date date)
  3. getWeekDay(Date dt, int weekDay)
  4. getWeekDay(int weekday)
  5. getWeekDay(String date)
  6. getWeekDay(String dateString, int weekDay)
  7. getWeekDay(String str)
  8. getWeekDayByDate(Date date)
  9. getWeekDayCN()