widana

Due Date Util

Nov 7th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package console;
  2.  
  3. import java.text.SimpleDateFormat;
  4. import java.util.Calendar;
  5.  
  6. public class DueDateUtil {
  7.  
  8.     public String getDueDateFromDate(String dateNow) {
  9.  
  10.         int constantFive = 5;
  11.         int constantTwenty = 20;
  12.         String dateNowAfterSubstring = dateNow.substring(0,6);
  13.         Calendar calendarDateNow = Calendar.getInstance();
  14.  
  15.        
  16.         int AfterSubstringGetDay = new Integer(dateNow.substring(6));
  17.  
  18.         if(AfterSubstringGetDay < constantFive || AfterSubstringGetDay == constantFive) {
  19.        
  20.             return dateNowAfterSubstring.concat("05");
  21.  
  22.         }
  23.        
  24.         if(AfterSubstringGetDay > constantFive && AfterSubstringGetDay <= constantTwenty) {
  25.        
  26.             return dateNowAfterSubstring.concat("20");
  27.  
  28.         } else  {
  29.  
  30.             calendarDateNow.add(Calendar.MONTH, 1);
  31.            
  32.             return new SimpleDateFormat("yyyyMMdd")
  33.                 .format(calendarDateNow.getTime())
  34.                 .substring(0,6)
  35.                 .concat("05");
  36.  
  37.  
  38.         }
  39.        
  40.     }
  41.    
  42. }
Add Comment
Please, Sign In to add comment