Java tutorial
//package com.java2s; public class Main { /** * For a given string that should contain an long value, return either the * <code>long</code> value or a zero if empty. * * @param irodsValue * @return <code>long</code> equivilent of irods value */ public static long getLongOrZeroFromIRODSValue(final String irodsValue) { long result = 0L; if (irodsValue == null) { throw new IllegalArgumentException("null irodsValue"); } if (irodsValue.isEmpty()) { // nothing } else { try { result = Long.parseLong(irodsValue); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("cannot format number:" + irodsValue, nfe); } } return result; } }