List of usage examples for java.lang Long parseLong
public static long parseLong(String s) throws NumberFormatException
From source file:Main.java
/** * Gets the String value as long./*from www . ja v a2s. com*/ */ public final static long getStringAsLong(String value) { return value == null ? -1 : Long.parseLong(value); }
From source file:Main.java
/** * Safely converts an object into an long * * @param obj//from w w w . j a va2 s . c o m * The object to convert. * @return a Long representing the long value of the Object (null if the * object cannot be converted to Long) */ public static Long safeJsonToLong(Object obj) { Long longValue; try { longValue = Long.parseLong(safeJsonToString(obj)); } catch (NumberFormatException e) { longValue = null; } return longValue; }
From source file:Main.java
/** * //ww w. j a va 2s . com * @param object * @return */ protected static Long toLong(Object object) { String str = toString(object); if ("".equals(str)) return 0l; else return Long.parseLong(str); }
From source file:Main.java
public static String formatData(String time) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return format.format(new Date(Long.parseLong(time))); }
From source file:Main.java
public static boolean isSameDay(String s1, String s2) { if (s1 == null || s2 == null) return false; Calendar c1 = Calendar.getInstance(); c1.setTime(new Date(Long.parseLong(s1))); Calendar c2 = Calendar.getInstance(); c2.setTime(new Date(Long.parseLong(s2))); return isSameDay(c1, c2); }
From source file:Main.java
public static long parseDuration(String icalDuration) { final int GROUP_SECONDS = 1; final String PATTERN = "-?P(\\d)+S"; long durationInSeconds = -1; Pattern p = Pattern.compile(PATTERN); Matcher m = p.matcher(icalDuration); if (m.groupCount() > 1) { durationInSeconds = Long.parseLong(m.group(GROUP_SECONDS)); }/* w ww . java2 s . co m*/ return durationInSeconds; }
From source file:Main.java
public static long intID() { Calendar c = Calendar.getInstance(); int dia = c.get(Calendar.DAY_OF_MONTH); int ano = c.get(Calendar.YEAR) - 2010; int mes = c.get(Calendar.MONTH) + 1; int hora = c.get(Calendar.HOUR_OF_DAY); int minuto = c.get(Calendar.MINUTE); int segundo = c.get(Calendar.SECOND); int milisec = c.get(Calendar.MILLISECOND); return Long.parseLong("" + ano + mes + dia + hora + minuto + segundo + milisec); }
From source file:Main.java
/** * /*from ww w.ja v a 2 s .com*/ * @Title: convertValType * @Description: TODO * @param value * @param fieldTypeClass * @return * @return: Object */ public static Object convertValType(Object value, Class<?> fieldTypeClass) { Object retVal = null; if (Long.class.getName().equals(fieldTypeClass.getName()) || long.class.getName().equals(fieldTypeClass.getName())) { retVal = Long.parseLong(value.toString()); } else if (Integer.class.getName().equals(fieldTypeClass.getName()) || int.class.getName().equals(fieldTypeClass.getName())) { retVal = Integer.parseInt(value.toString()); } else if (Float.class.getName().equals(fieldTypeClass.getName()) || float.class.getName().equals(fieldTypeClass.getName())) { retVal = Float.parseFloat(value.toString()); } else if (Double.class.getName().equals(fieldTypeClass.getName()) || double.class.getName().equals(fieldTypeClass.getName())) { retVal = Double.parseDouble(value.toString()); } else { retVal = value; } return retVal; }
From source file:com.architexa.rse.DateUtil.java
public static Date getLicenseValidity(String licenseKey) { String[] parts = licenseKey.split("::"); if (parts.length != 2 || !parts[0].equals("atxa")) return null; String newPass = new String(Base64.decodeBase64((parts[1]).getBytes())); String[] passParts = newPass.split("::"); long expiry = Long.parseLong(passParts[2]); return new Date(expiry); }
From source file:Main.java
/** * parse value to long// ww w . j av a 2s. c o m */ public static long toLong(String value) { return TextUtils.isEmpty(value) ? 0 : Long.parseLong(value); }