Java Minute Get getMinutes(String hora)

Here you can find the source of getMinutes(String hora)

Description

get Minutes

License

Apache License

Declaration

public static Integer getMinutes(String hora) 

Method Source Code


//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;
    }
}

Related

  1. getMinutes(double seconds)
  2. getMinutes(double t)
  3. getMinutes(final double DEC_DEG)
  4. getMinutes(int minutes)
  5. getMinutes(long time)
  6. getMinutes(String time)
  7. getMinutes(String time, int defaultValue)
  8. getMinutesDiff(long from, long to)
  9. getMinutesInSecWOHours(long sec)