List of usage examples for java.lang Long parseLong
public static long parseLong(String s) throws NumberFormatException
From source file:Main.java
public static long[] strToArrayOfLong(String str) { StringTokenizer tmpst = new StringTokenizer(str, "|", false); int len = tmpst.countTokens(); long[] retl = new long[len]; for (int i = 0; i < len; i++) { retl[i] = Long.parseLong(tmpst.nextToken()); }//from w w w . j av a2 s . com return retl; }
From source file:Main.java
private static Object convertValType(Object value, Class fieldTypeClass) { Object retVal = null;//from w w w . ja v a2 s. c o m 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:Main.java
public static long[] convert(Object[] objs) { long[] array = new long[0]; if (objs == null) { return array; } else {/*from w w w . j a v a 2 s .co m*/ array = new long[objs.length]; } for (int i = 0; i < objs.length; i++) { array[i] = Long.parseLong(objs[i].toString()); } return array; }
From source file:Main.java
public static long getDateAsHeaderId(long milliseconds) { SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy", Locale.getDefault()); return Long.parseLong(dateFormat.format(new Date(milliseconds))); }
From source file:Main.java
public static long getUserId(AccountManager paramAccountManager, Account paramAccount) { String str = paramAccountManager.getUserData(paramAccount, "account_user_info"); if (str != null) return Long.parseLong(str); return 0L;/*from ww w . j av a 2 s . c o m*/ }
From source file:Main.java
public static String igFormattedDate(String timestamp) { /**//from w w w.j ava2 s .c o m * From the group discussion board. */ CharSequence relativeDateTimeString = DateUtils.getRelativeTimeSpanString(Long.parseLong(timestamp) * 1000, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS); return relativeDateTimeString.toString().replaceAll("[^0-9]+", "s"); }
From source file:Main.java
public static String timestempToStringMore(String time) { return HM_FORMAT.format(new Date(Long.parseLong(time) * 1000)); }
From source file:Main.java
public static String timestempToStringMore2(String time) { return HM_FORMAT.format(new Date(Long.parseLong(time))); }
From source file:Main.java
public synchronized static Long createId() { int max = 999; int min = 100; Random random = new Random(); Integer s = random.nextInt(max) % (max - min + 1) + min; Long currentTimeMillis = System.currentTimeMillis(); return Long.parseLong(currentTimeMillis.toString() + s.toString()); }
From source file:Main.java
public static Long convertToLong(String longStr) { try {/* w w w. ja v a 2 s.co m*/ return Long.parseLong(longStr); } catch (NumberFormatException e) { } return null; }