Java Day of getDisplayDate(final Date date, final int offsetDays)

Here you can find the source of getDisplayDate(final Date date, final int offsetDays)

Description

get Display Date

License

Open Source License

Declaration

public static String getDisplayDate(final Date date, final int offsetDays) 

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final DateFormat DISPLAY_FORMAT = new SimpleDateFormat("E : dd-MMM");

    public static String getDisplayDate(final Date date, final int offsetDays) {
        String val = null;

        if (date != null) {
            Date offsetDate = date;

            if (offsetDays > 0) {
                offsetDate = getDateAfter(date, offsetDays);
            }//from   w w  w.  j a v a 2 s. c om

            val = DISPLAY_FORMAT.format(offsetDate);
        }

        return val;
    }

    public static Date getDateAfter(Date date, int increment) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        calendar.add(Calendar.DAY_OF_YEAR, increment);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        return calendar.getTime();
    }
}

Related

  1. getDataTimeForwordDay(Date date, int dayNum)
  2. getDefaultOffsetDays(String strDate)
  3. getDeltaDay(String day, int delta)
  4. getDeltaDays(String date)
  5. getDeltaNow(int deltaDays)
  6. getEndDayofMouth(String date, String inPattern, String outPattern)
  7. getFirstDay(boolean isNeedHH24MISS)
  8. getFirstDay(boolean withTime)
  9. getFirstDay(Date date)