Necesita obtener tiempo en un formato de 24 horas al tiempo que añade

Había escrito una función para añadir tiempo como se indica a continuación

private void Delay15Minute() { String pkManifest = manifest.pkManifestNo; manifest_helper = new manifest_helper(this); cursor = manifest_helper.GetDeliveries(pkManifest); cursor.moveToFirst(); for (int i = 0; i < cursor.getCount(); i++) { cursor.getString(cursor.getColumnIndex("PKDelivery")); // String // RevisedTime=cursor.getString(cursor.getColumnIndex("RevisedEstimatedDeliveryTime")); String RevisedTime = "12:55"; // get hour and minute from time string StringTokenizer st1 = new StringTokenizer(RevisedTime, ":"); int j = 0; int[] val = new int[st1.countTokens()]; // iterate through tokens while (st1.hasMoreTokens()) { val[j] = Integer.parseInt(st1.nextToken()); j++; } // call time add method with current hour, minute and minutesToAdd, // return added time as a string String date = addTime(val[0], val[1], 15); // Tioast the new time Toast.makeText(this, "date is =" + date, Toast.LENGTH_SHORT).show(); } } public String addTime(int hour, int minute, int minutesToAdd) { Calendar calendar = new GregorianCalendar(1990, 1, 1, hour, minute); calendar.add(Calendar.MINUTE, minutesToAdd); SimpleDateFormat sdf = new SimpleDateFormat("hh:mm"); String date = sdf.format(calendar.getTime()); return date; } 

Estoy recibiendo el outpt de esto como 01:10 como 12 horas fromat …

Necesito conseguirla en el formato 13:10 es decir formato de 24 horas ….. Por favor ayúdeme

Usó hh en su patrón de SimpleDateFormat . Ése es el formato de 12 horas. Use kk lugar, que le da las horas del día en un formato de 24 horas. Consulte SimpleDateFormat .

Simplemente crear la instancia de Calendar y obtener 24 horas por,

 Calendar c = Calendar.getInstance(); int Hr24=c.get(Calendar.HOUR_OF_DAY); int Min=c.get(Calendar.MINUTE); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.