Here you can find the source of getMinutes(String hora)
public static Integer getMinutes(String hora)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Integer getMinutes(String hora) { Integer Minutes;//from www .j ava2 s. co m int h, m; try { SimpleDateFormat format1 = new SimpleDateFormat("H:m:s"); Date dt1 = format1.parse(hora); DateFormat format2 = new SimpleDateFormat("H"); h = Integer.valueOf(format2.format(dt1)); /* SOLO TENER EN CUENTA LAS HORAS format2=new SimpleDateFormat("m"); m=Integer.valueOf(format2.format(dt1)); */ m = 0; Minutes = new Integer(h * 60 + m); } catch (Exception ex) { try { h = Integer.valueOf(hora.substring(0, 2)); /* SOLO TENER EN CUENTA LAS HORAS*/ //m=Integer.valueOf(hora.substring(2, 4)); m = 0; Minutes = new Integer(h * 60 + m); } catch (Exception ex2) { Minutes = new Integer(-1); } } return Minutes; } }