Java Week getNextWeek(String week)

Here you can find the source of getNextWeek(String week)

Description

get Next Week

License

Apache License

Declaration

public static String getNextWeek(String week) 

Method Source Code


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

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

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

public class Main {
    public static String getNextWeek(String week) {
        return getDeltaWeek(week, 1);
    }//from   www  . j  a  va  2 s  .  com

    public static String getDeltaWeek(String week, int delta) {
        GregorianCalendar rightNow = new GregorianCalendar();
        try {
            Date date = getDefaultWeekFormat().parse(week);
            rightNow.setTime(date);
            rightNow.add(Calendar.WEEK_OF_YEAR, delta);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return getDefaultWeekFormat().format(rightNow.getTime());
    }

    public static SimpleDateFormat getDefaultWeekFormat() {
        return new SimpleDateFormat("yyyyww");
    }
}

Related

  1. currentWeekEndDate()
  2. getPreWeek(String week)
  3. getPreWeekDayByStr(String curday)
  4. getPreWeekDayByStr(String curday)
  5. getPreWeeks(int weekNum)