SHARE
TWEET

Untitled

a guest Jun 25th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @NonNull
  2.     public static String increaseTimeString(String time, int valHours, int valMinutes, boolean saveToDB, String ID, Context context, TimeSavingColumn column){   // time (hh:mm) // czas pojawienia się zadania + czas na akceptację
  3.         String[] tTime = time.split(":");
  4.         String hour = tTime[0];
  5.         String minute = tTime[1];
  6.         tTime = null;
  7.         if(hour.startsWith("0")) {
  8.             tTime = hour.split("0");
  9.             if(tTime.length > 0)  hour = tTime[0];
  10.             else hour = "0";
  11.         }
  12.         tTime = null;
  13.         if(minute.startsWith("0")) {
  14.             tTime = minute.split("0");
  15.             if (tTime.length > 0) minute = tTime[0];
  16.             else minute = "0";
  17.         }
  18.  
  19.         int iHour = Integer.parseInt(hour);
  20.         int iMinute = Integer.parseInt(minute);
  21.  
  22.         if(valMinutes != -1){
  23.             iMinute = iMinute + valMinutes;
  24.             while (iMinute >= 60){
  25.                 iMinute = iMinute - 60;
  26.                 iHour++;
  27.             }
  28.         }
  29.  
  30.         int days = 0;
  31.  
  32.         iHour = iHour + valHours;
  33.  
  34.         String day = String.valueOf(days);
  35.  
  36.         if (iHour < 10 && iHour > 0) {
  37.             hour = "0" + String.valueOf(iHour);
  38.         } else {
  39.             hour = String.valueOf(iHour);
  40.         }
  41.         if (iMinute < 10) {
  42.             minute = "0" + String.valueOf(iMinute);
  43.         } else {
  44.             minute = String.valueOf(iMinute);
  45.         }
  46.  
  47.         if(saveToDB){
  48.             DBAcceptedTasks database = new DBAcceptedTasks(context);
  49.             database.open();
  50.             String actualTime = hour + ":" + minute;
  51.             if (column == TimeSavingColumn.START)database.updateTask(ID, null, null, null, null, -1, -1, -1, -1, -1, -1, actualTime, null, null);
  52.             if (column == TimeSavingColumn.END)database.updateTask(ID, null, null, null, null, -1, -1, -1, -1, -1, -1, null, actualTime, null);
  53.             if (column == TimeSavingColumn.END)database.updateTask(ID, null, null, null, null, -1, -1, -1, -1, -1, -1, null, null, actualTime);
  54.         }
  55.  
  56.         return hour + ":" + minute;
  57.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top