Here you can find the source of parseSeconds(String value, int defaultValue)
public static int parseSeconds(String value, int defaultValue)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w .ja va 2s . c o m*/ * Returns {@code value} as a positive integer, or 0 if it is negative, or * {@code defaultValue} if it cannot be parsed. */ public static int parseSeconds(String value, int defaultValue) { try { long seconds = Long.parseLong(value); if (seconds > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } else if (seconds < 0) { return 0; } else { return (int) seconds; } } catch (NumberFormatException e) { return defaultValue; } } }