Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package console;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- public class DueDateUtil {
- public String getDueDateFromDate(String dateNow) {
- int constantFive = 5;
- int constantTwenty = 20;
- String dateNowAfterSubstring = dateNow.substring(0,6);
- Calendar calendarDateNow = Calendar.getInstance();
- int AfterSubstringGetDay = new Integer(dateNow.substring(6));
- if(AfterSubstringGetDay < constantFive || AfterSubstringGetDay == constantFive) {
- return dateNowAfterSubstring.concat("05");
- }
- if(AfterSubstringGetDay > constantFive && AfterSubstringGetDay <= constantTwenty) {
- return dateNowAfterSubstring.concat("20");
- } else {
- calendarDateNow.add(Calendar.MONTH, 1);
- return new SimpleDateFormat("yyyyMMdd")
- .format(calendarDateNow.getTime())
- .substring(0,6)
- .concat("05");
- }
- }
- }
Add Comment
Please, Sign In to add comment