List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:Main.java
public static long ip2int(String ip) { ip = ip.replace(".", ","); String[] items = ip.split(","); return Long.valueOf(items[0]) << 24 | Long.valueOf(items[1]) << 16 | Long.valueOf(items[2]) << 8 | Long.valueOf(items[3]); }
From source file:Main.java
public static <T> T getData(Context context, String fileName, String key, Class T) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); T result;// www .j a v a2s . c om if (String.class.isAssignableFrom(T)) { result = (T) sharedPreferences.getString(key, ""); } else if (Integer.class.isAssignableFrom(T)) { result = (T) Integer.valueOf(sharedPreferences.getInt(key, 0)); } else if (Float.class.isAssignableFrom(T)) { result = (T) Float.valueOf(sharedPreferences.getFloat(key, 0)); } else if (Long.class.isAssignableFrom(T)) { result = (T) Long.valueOf(sharedPreferences.getLong(key, 0)); } else { result = (T) Boolean.valueOf(sharedPreferences.getBoolean(key, false)); } return result; }
From source file:Main.java
public static String[] getCalendarShowTime(String paramString) { try {//w ww. j a v a 2 s .com long l = Long.valueOf(paramString); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTimeInMillis(1000L * l); return getCalendarShowTime(localCalendar.getTimeInMillis()); } catch (NumberFormatException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getReadableDateString(String time) { try {/*from w w w. j av a2s. c o m*/ Date date = new Date(Long.valueOf(time) * 1000); SimpleDateFormat format = new SimpleDateFormat("yyyy. MM. dd."); return format.format(date).toString(); } catch (Exception e) { return "0"; } }
From source file:Main.java
public static String getReadableDateTimeString(String time) { try {/*from w ww. j a v a 2s . c o m*/ Date date = new Date(Long.valueOf(time) * 1000); SimpleDateFormat format = new SimpleDateFormat(" HH "); return format.format(date).toString(); } catch (Exception e) { e.printStackTrace(); return "0"; } }
From source file:Main.java
/** * box the long to Long */ public static Long boxed(long v) { return Long.valueOf(v); }
From source file:com.nokia.example.rlinks.model.RedditComment.java
public static RedditComment fromJson(JSONObject obj) throws JSONException { RedditComment comment = new RedditComment(); comment.setAuthor(obj.optString("author")); comment.setBody(obj.optString("body")); comment.setCreated(new Date(Long.valueOf(obj.optLong("created")) * 1000)); return comment; }
From source file:Main.java
static long longElement(Element row, String name) { return Long.valueOf(stringElement(row, name)).longValue(); }
From source file:Main.java
public static void bindValores(SQLiteStatement statement, ContentValues contentValues) { Set<String> chaves = new TreeSet<>(contentValues.keySet()); int index = 1; for (String chave : chaves) { Object valor = contentValues.get(chave); if (valor == null) { statement.bindNull(index);/*from w w w .j a v a 2s. c o m*/ } else if (valor instanceof String) { statement.bindString(index, (String) valor); } else if (valor instanceof Double || valor instanceof Float) { statement.bindDouble(index, Double.valueOf(String.valueOf(valor))); } else if (valor instanceof Integer || valor instanceof Long) { statement.bindLong(index, Long.valueOf(String.valueOf(valor))); } else if (valor instanceof byte[]) { statement.bindBlob(index, (byte[]) valor); } index++; } }
From source file:Main.java
public static long getMaxCpuFreq() { long longRet = 0; String result = "0"; ProcessBuilder cmd;//from ww w . j av a 2 s . c o m try { String[] args = { "/system/bin/cat", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" }; cmd = new ProcessBuilder(args); Process process = cmd.start(); InputStream in = process.getInputStream(); byte[] re = new byte[24]; result = ""; while (in.read(re) != -1) { result = result + new String(re); } in.close(); } catch (IOException ex) { ex.printStackTrace(); result = "0"; } if (result.length() != 0) { try { longRet = Long.valueOf(result.trim()); } catch (Exception e) { android.util.Log.e(TAG, ""); } } return longRet; }