Java Day of Week getDayWeekDateStr(Date date)

Here you can find the source of getDayWeekDateStr(Date date)

Description

get Day Week Date Str

License

Open Source License

Declaration

public static String getDayWeekDateStr(Date date) 

Method Source Code

//package com.java2s;
/**//from  ww  w.ja  va 2 s. com
* License: https://github.com/votingsystem/votingsystem/wiki/Licencia
*/

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getDayWeekDateStr(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        if (Calendar.getInstance().get(Calendar.YEAR) != calendar.get(Calendar.YEAR))
            return getDateStr(date, "dd MMM yyyy' 'HH:mm");
        else
            return getDateStr(date, "EEE dd MMM' 'HH:mm");
    }

    public static String getDateStr(Date date) {
        DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd' 'HH:mm:ss");
        return formatter.format(date);
    }

    public static String getDateStr(Date date, String format) {
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        return formatter.format(date);
    }
}

Related

  1. getDayofWeekByDay(String year, String month, String day)
  2. getDayofWeekForContainedDate(Date dt, DayOfWeek dow)
  3. getDaysByWeek(Integer month, Integer year, Integer week)
  4. getDaysByWeek2(Integer month, Integer year, Integer begin)
  5. getDayWeekDate(String dateStr)
  6. getEndOfWeek(Date date)
  7. getFirstDayOfLastWeek(Date date)
  8. getFirstDayOfWeek(int year, int week)
  9. getFirstDayOfWeek(int year, int week)