Java Day of Week getWeekDays(String _date, int _amount)

Here you can find the source of getWeekDays(String _date, int _amount)

Description

get Week Days

License

Open Source License

Declaration

public static String getWeekDays(String _date, int _amount) 

Method Source Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static String getWeekDays(String _date, int _amount) {
        String res;/*from  w ww .  j  a  va  2s  .c  om*/

        int year = Integer.parseInt(_date.substring(0, 4));
        int month = Integer.parseInt(_date.substring(4, 6));
        int day = Integer.parseInt(_date.substring(6, 8));

        Calendar wCal = Calendar.getInstance();
        wCal.set(year, month - 1, day);
        wCal.add(Calendar.DATE, _amount);

        year = wCal.get(Calendar.YEAR);
        month = wCal.get(Calendar.MONTH) + 1;
        day = wCal.get(Calendar.DATE);

        res = Integer.toString(year);

        if (month < 10)
            res += "0" + Integer.toString(month);
        else
            res += Integer.toString(month);

        if (day < 10)
            res += "0";

        res += Integer.toString(day);

        return res;
    }
}

Related

  1. getWeekDay(Date dt, int weekDay)
  2. getWeekDay(String strDate)
  3. getWeekdayDate(Date actualDate)
  4. getWeekdayInterval(Date date)
  5. getWeekDayOfYear(Date date)
  6. getWeekDaysBetween(Date fromDate, Date toDate, int dayOfWeek)
  7. getWeekEnd(Date date, int w)
  8. getWeekFirstDay(Date weekday)
  9. getWeekID(Date dateValue)