List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:Main.java
/** * @param date/* w ww.java2s . c o m*/ * Date for which seconds since the epoch date is to be calculated * @return Number of seconds after the unix epoch date equivalent to the given date */ public static Integer secondsSinceUnixEpoch(final LocalDateTime date) { if (date == null) { return null; } final Long timeInSeconds = Long.valueOf(date.toEpochSecond(ZoneOffset.UTC)); return Integer.valueOf(timeInSeconds.intValue()); }
From source file:Main.java
public static String unixTimestampToDate(String unixDate) { long dv = Long.valueOf(unixDate) * 1000;// its need to be in milisecond Date df = new Date(dv); String dateString = new SimpleDateFormat("yyyy-MM-dd hh:mm a").format(df); return dateString; }
From source file:Main.java
public static void sortFileByDate(List<File> allFileList) { File[] files = new File[allFileList.size()]; for (int i = 0; i < allFileList.size(); i++) { files[i] = allFileList.get(i);/*from ww w. j a v a 2 s . com*/ } Arrays.sort(files, new Comparator<File>() { public int compare(File f1, File f2) { return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); } }); allFileList.clear(); allFileList.addAll(Arrays.asList(files)); }
From source file:Main.java
public static String getFormatSecondTime(String time) { if (TextUtils.isEmpty(time)) return null; return getFormatSecondTime(Long.valueOf(time)); }
From source file:Main.java
public static void RegisterUnoFallback(String javaTypeName, long unoTypePtr) { Class<?> cls = null;//from w ww.ja v a 2 s. c om try { cls = Class.forName(javaTypeName); } catch (ClassNotFoundException ignore) { } unoFallbacks.put(Long.valueOf(unoTypePtr), cls); unoFallbacksClassToPtr.put(cls, Long.valueOf(unoTypePtr)); }
From source file:Main.java
/** * Gets a long value of the given attribute * @param node/*from ww w . jav a2 s. co m*/ * @param attrName * @param defaultValue * @return */ public static long getLongValue(Node node, String attrName, long defaultValue) { String value = getValue(node, attrName, null); if (value == null) return defaultValue; try { return Long.valueOf(value); } catch (NumberFormatException e) { return defaultValue; } }
From source file:Main.java
public static String toNumberComma(String text) { String ret = ""; String number = ""; for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch >= '0' && ch <= '9') { number += ch;//from w w w . j a va 2 s .c o m } else { if (number.length() != 0) { if (number.charAt(0) != '0') { ret += getPriceToWon(Long.valueOf(number)); } else { ret += number; } number = ""; } ret += ch; } } if (number.length() != 0) { if (number.charAt(0) != '0') { ret += getPriceToWon(Long.valueOf(number)); } else { ret += number; } } return ret; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getPref(Context _context, String prefKey, T defValue, Class<T> clazz) { final SharedPreferences pref = getDefaultSharedPreferences(_context); if (Long.class == clazz) { return (T) (Long.valueOf(pref.getLong(prefKey, (Long) defValue))); } else if (Integer.class == clazz) { return (T) (Integer.valueOf(pref.getInt(prefKey, (Integer) defValue))); } else if (defValue instanceof String) { return (T) (pref.getString(prefKey, String.valueOf(defValue))); } else if (defValue instanceof Boolean) { return (T) (Boolean.valueOf(pref.getBoolean(prefKey, (Boolean) defValue))); }// www.j ava2s. c o m throw new UnsupportedOperationException("Class " + clazz + " not supported"); }
From source file:Main.java
private static Object[] toArrayByString(String str) { List<Object> result = new ArrayList<Object>(); str = str.substring(1, str.length() - 1); String type = str.substring(0, str.indexOf("@")); String[] values = str.substring(str.indexOf("@") + 1).split(","); for (int i = 0; i < values.length; i++) { String value = unesc(values[i]); if ("java.lang.Long".equals(type)) result.add(Long.valueOf(value)); else if ("java.lang.Integer".equals(type)) result.add(Integer.valueOf(value)); else {/* w w w .j a v a 2 s . c om*/ result.add(value); } } return result.toArray(); }
From source file:Main.java
public static long asLong(Object node, String key, long def) { Object value;/*from ww w . ja v a 2 s.c o m*/ if ((node instanceof HashMap<?, ?>) && ((value = ((HashMap<?, ?>) node).get(key)) != null)) { if (value instanceof Number) { return ((Number) value).longValue(); } else { try { return Long.valueOf(value.toString()); } catch (NumberFormatException ex) { return def; } } } else { return def; } }