List of usage examples for java.lang Long parseLong
public static long parseLong(String s) throws NumberFormatException
From source file:Main.java
public static final long objectToLong(Object o) { if (o instanceof Number) return ((Number) o).longValue(); try {//from w ww. ja v a2 s .c om if (o == null) return -1L; else return Long.parseLong(o.toString()); } catch (NumberFormatException e) { e.printStackTrace(); return -1L; } }
From source file:Main.java
static long[] deserializePattern(final String patternString) { final String[] temp = patternString.split("-"); final long[] toReturn = new long[temp.length]; for (int i = 0; i < temp.length; ++i) { toReturn[i] = Long.parseLong(temp[i]); }//w w w . j av a 2 s . co m return toReturn; }
From source file:Main.java
public static BigDecimal formatToYuan(String money) throws NumberFormatException { if (money.equals("")) { return new BigDecimal(0); }// w w w.java 2 s .c om long m = Long.parseLong(money); return BigDecimal.valueOf(m); }
From source file:Main.java
public static String getDFDateString(String timeStamp) { try {/*from w w w .j a v a2s . c o m*/ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy @ H:mm"); Date date = new Date(Long.parseLong(timeStamp) * 1000); return dateFormat.format(date); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:Main.java
public static String floatToDuration(String duration_in_float) { duration_in_float = String.format("%2.2f", Float.parseFloat(duration_in_float)); String[] parts = duration_in_float.split("\\."); long minute = Long.parseLong(parts[0]); long seconds = (60 * Long.parseLong(parts[1])) / 100; return String.format("%02d:%02d", minute, seconds); }
From source file:Main.java
public static boolean isToday(final String milliseconds) { if (TextUtils.isEmpty(milliseconds)) return false; return isToday(new Date(Long.parseLong(milliseconds))); }
From source file:Main.java
public static long bundleGetStringLong(Bundle bundle, String key) { if (bundle == null) return -1; String s = bundle.getString(key); if (s == null) return -1; try {//from w w w.j av a 2s . c o m return Long.parseLong(s); } catch (NumberFormatException e) { return -1; } }
From source file:Main.java
public static long getLong(Node aNode, String attr, long defaultValue) { if (aNode.getAttributes().getNamedItem(attr) != null) { String attrString = aNode.getAttributes().getNamedItem(attr).getNodeValue(); Long year = Long.parseLong(attrString); return year; } else {/*from w w w .j a va 2 s . c o m*/ return defaultValue; } }
From source file:Main.java
public static Uri getContactUri(String contactId) { return ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(contactId)); }
From source file:Main.java
/** * Extracts a Long from a document that consists of a Long only. * // www . ja v a 2 s .co m * @param doc * @return the Long */ public static Long extractLong(Node doc) { if (doc == null) { return 0l; } return Long.parseLong(doc.getFirstChild().getTextContent()); }