i need to add certain minutes to util.time variable, and to do that code implemented is
public java.sql.Time getSQLTime(String time,int min) throws ParseException{ DateFormat sdf = new SimpleDateFormat("hh:mm"); Date date = sdf.parse(time); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MINUTE, (min+30)); //System.out.println(" Minutes to be added:"+min); date = utilDateToSqlTime(calendar.getTime()); //System.out.println("updated sql time"+date); return new java.sql.Time(date.getTime()); }
i parameter time is in (hh:mm) format and is converted into util.time object with help of parse method.
this above method returns sql.time. this code works fine except when the is set to [12:min] say time= 12:30 and i have to add 150 minutes to it then expected outcome should be 15:00:00 but the actual out come is 03:00:00.
note: when 11:30 is passed and minutes to add 150, then outcome is 14:00:00.
this problem persist. check the output for the range 11:58 to 13:00 and minutes to be added is 150
thank you!time passed:11:58 returned time 14:28:00 time passed:11:59 returned time 14:29:00 time passed:12:00 returned time 02:30:00 time passed:12:01 returned time 02:31:00 time passed:12:02 returned time 02:32:00 time passed:12:03 returned time 02:33:00 time passed:12:04 returned time 02:34:00 time passed:12:05 returned time 02:35:00 time passed:12:06 returned time 02:36:00 time passed:12:07 returned time 02:37:00 time passed:12:08 returned time 02:38:00 time passed:12:09 returned time 02:39:00 time passed:12:10 returned time 02:40:00 time passed:12:11 returned time 02:41:00 time passed:12:12 returned time 02:42:00 time passed:12:13 returned time 02:43:00 time passed:12:14 returned time 02:44:00 time passed:12:15 returned time 02:45:00 time passed:12:16 returned time 02:46:00 time passed:12:17 returned time 02:47:00 time passed:12:18 returned time 02:48:00 time passed:12:19 returned time 02:49:00 time passed:12:20 returned time 02:50:00 time passed:12:21 returned time 02:51:00 time passed:12:22 returned time 02:52:00 time passed:12:23 returned time 02:53:00 time passed:12:24 returned time 02:54:00 time passed:12:25 returned time 02:55:00 time passed:12:26 returned time 02:56:00 time passed:12:27 returned time 02:57:00 time passed:12:28 returned time 02:58:00 time passed:12:29 returned time 02:59:00 time passed:12:30 returned time 03:00:00 time passed:12:31 returned time 03:01:00 time passed:12:32 returned time 03:02:00 time passed:12:33 returned time 03:03:00 time passed:12:34 returned time 03:04:00 time passed:12:35 returned time 03:05:00 time passed:12:36 returned time 03:06:00 time passed:12:37 returned time 03:07:00 time passed:12:38 returned time 03:08:00 time passed:12:39 returned time 03:09:00 time passed:12:40 returned time 03:10:00 time passed:12:41 returned time 03:11:00 time passed:12:42 returned time 03:12:00 time passed:12:43 returned time 03:13:00 time passed:12:44 returned time 03:14:00 time passed:12:45 returned time 03:15:00 time passed:12:46 returned time 03:16:00 time passed:12:47 returned time 03:17:00 time passed:12:48 returned time 03:18:00 time passed:12:49 returned time 03:19:00 time passed:12:50 returned time 03:20:00 time passed:12:51 returned time 03:21:00 time passed:12:52 returned time 03:22:00 time passed:12:53 returned time 03:23:00 time passed:12:54 returned time 03:24:00 time passed:12:55 returned time 03:25:00 time passed:12:56 returned time 03:26:00 time passed:12:57 returned time 03:27:00 time passed:12:58 returned time 03:28:00 time passed:12:59 returned time 03:29:00 time passed:13:00 returned time 15:30:00