public static Integer durToInteger(String meta, String date, String time) { Integer index = 0; Long y; Integer hh, mm, day, year, mo, interInMinutes; String part[] = meta.split(","); hh = Integer.valueOf(part[1]); mm = Integer.valueOf(part[2]); day = Integer.valueOf(part[3]); year = Integer.valueOf(part[4]); interInMinutes = Integer.valueOf(part[5]); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, hh); cal.set(Calendar.MINUTE, mm); cal.set(Calendar.SECOND, 0); cal.set(Calendar.DAY_OF_YEAR, day); cal.set(Calendar.YEAR, year); Date d1 = cal.getTime(); Date t = new Date(); SimpleDateFormat tf = new SimpleDateFormat("hh:mm a"); SimpleDateFormat pf = new SimpleDateFormat("HH:mm"); try { t = tf.parse(time); } catch (java.text.ParseException e) { e.printStackTrace(); } String[] strs = pf.format(t).split(":"); hh = Integer.valueOf(strs[0]); mm = Integer.valueOf(strs[1]); String[] spl = date.split(", "); String[] spl2 = spl[0].split(" "); day = Integer.valueOf(spl2[0]); mo = Integer.valueOf(spl2[1]); year = Integer.valueOf(spl2[2]); Calendar cal2 = Calendar.getInstance(); cal2.set(Calendar.HOUR_OF_DAY, hh); cal2.set(Calendar.MINUTE, mm); cal2.set(Calendar.SECOND, 0); cal2.set(Calendar.DATE, day); cal2.set(Calendar.MONTH, mo - 1); cal2.set(Calendar.YEAR, year); Date d2 = cal2.getTime(); date = spl2[0] + " " + new DateFormatSymbols().getMonths()[mo - 1] + ", " + spl[1]; Map<TimeUnit, Long> DiffMap = Utility.computeDiff(d1, d2); y = DiffMap.get(TimeUnit.DAYS) * 24 * 60 + DiffMap.get(TimeUnit.HOURS) * 60 + DiffMap.get(TimeUnit.MINUTES); y = y / interInMinutes + 1; index = (int) (long) y; return index; }