Java Second Format _toSeconds(String strTime)

Here you can find the source of _toSeconds(String strTime)

Description

to Seconds

License

Apache License

Declaration

private static Float _toSeconds(String strTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static Float _toSeconds(String strTime) {
        Float time = 0F;/*from w  w  w  .j a  v  a 2  s  .  c om*/
        try {
            if (strTime.endsWith("s")) {
                time = Float.parseFloat(strTime.replace("s", "")) * 1;
            } else if (strTime.endsWith("m")) {
                time = Float.parseFloat(strTime.replace("m", "")) * 60;
            } else if (strTime.endsWith("h")) {
                time = Float.parseFloat(strTime.replace("h", "")) * 60 * 60;
            } else if (strTime.endsWith("d")) {
                time = Float.parseFloat(strTime.replace("d", "")) * 60 * 60 * 24;
            } else
                time = Float.parseFloat(strTime);
        } catch (Throwable e) {

        }

        return time;
    }
}

Related

  1. addSecondCa(String d1, int timeSpan, String format)
  2. calculateTimeInSeconds(long startTimeInMilliseconds, long endTimeInMilliseconds)
  3. changeSecondsToTime(long seconds)
  4. compareDate(String fistDate, String secondDate, String format)