List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:com.livinglogic.ul4.FunctionInt.java
public static Object call(Object obj) { if (obj instanceof String) { try {//from w w w . j a v a 2 s . c o m return Integer.valueOf((String) obj); } catch (NumberFormatException ex1) { try { return Long.valueOf((String) obj); } catch (NumberFormatException ex2) { return new BigInteger((String) obj); } } } else if (obj instanceof Integer || obj instanceof Byte || obj instanceof Short || obj instanceof Long) return obj; else if (obj instanceof BigInteger) return Utils.narrowBigInteger((BigInteger) obj); else if (obj instanceof Boolean) return ((Boolean) obj).booleanValue() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO; else if (obj instanceof Float || obj instanceof Double) return ((Number) obj).intValue(); else if (obj instanceof BigDecimal) return ((BigDecimal) obj).toBigInteger(); throw new ArgumentTypeMismatchException("int({})", obj); }
From source file:net.jakobnielsen.imagga.convert.ConverterTools.java
public static Long getLong(String key, Object o) { return Long.valueOf(getString(key, o)); }
From source file:Main.java
public static Element createTextElement(Element parent, String tagName, long v) { return createTextElement(parent, tagName, Long.valueOf(v).toString()); }
From source file:com.cloudmine.api.rest.ResponseTimeDataStore.java
public static void extractAndStoreResponseTimeInformation(Callback callback, HttpResponse response) { long startTime = callback.getStartTime(); long finishTime = System.currentTimeMillis(); Long responseTime = Long.valueOf(finishTime - startTime); Header[] headers = response.getHeaders(HeaderFactory.REQUEST_ID_KEY); if (headers.length == 0) { LOG.error("No request id headers returned from server"); return;//from www . j av a 2 s . c o m } for (Header header : headers) { String requestId = header.getValue(); responseMap.put(requestId, responseTime); } }
From source file:com.nokia.example.rlinks.model.RedditLink.java
public static RedditLink fromJson(JSONObject obj) throws JSONException { RedditLink rli = new RedditLink(); rli.setAuthor(obj.getString("author")); rli.setCreated(new Date(Long.valueOf(obj.getLong("created")) * 1000)); rli.setDomain(obj.getString("domain")); rli.setId(obj.getString("id")); rli.setNumComments(obj.getInt("num_comments")); rli.setPermalink(obj.getString("permalink")); rli.setSubreddit(obj.getString("subreddit")); rli.setScore(obj.getInt("score")); rli.setThumbnail(obj.getString("thumbnail")); rli.setTitle(obj.getString("title")); rli.setUrl(obj.getString("url")); return rli;/*www . j a va 2 s.co m*/ }
From source file:Main.java
private static Object readThisPrimitiveValueXml(XmlPullParser parser, String tagName) throws XmlPullParserException { try {//from w w w.j a va2 s . co m switch (tagName) { case "int": return Integer.parseInt(parser.getAttributeValue(null, "value")); case "long": return Long.valueOf(parser.getAttributeValue(null, "value")); case "float": return Float.valueOf(parser.getAttributeValue(null, "value")); case "double": return Double.valueOf(parser.getAttributeValue(null, "value")); case "boolean": return Boolean.valueOf(parser.getAttributeValue(null, "value")); default: return null; } } catch (NullPointerException e) { throw new XmlPullParserException("Need value attribute in <" + tagName + ">"); } catch (NumberFormatException e) { throw new XmlPullParserException("Not a number in value attribute in <" + tagName + ">"); } }
From source file:Main.java
private static final Object readThisPrimitiveValueXml(XmlPullParser parser, String tagName) throws XmlPullParserException, java.io.IOException { try {/*from w ww . j a va 2s .c o m*/ if (tagName.equals("int")) { return Integer.parseInt(parser.getAttributeValue(null, "value")); } else if (tagName.equals("long")) { return Long.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("float")) { return new Float(parser.getAttributeValue(null, "value")); } else if (tagName.equals("double")) { return new Double(parser.getAttributeValue(null, "value")); } else if (tagName.equals("boolean")) { return Boolean.valueOf(parser.getAttributeValue(null, "value")); } else { return null; } } catch (NullPointerException e) { throw new XmlPullParserException("Need value attribute in <" + tagName + ">"); } catch (NumberFormatException e) { throw new XmlPullParserException("Not a number in value attribute in <" + tagName + ">"); } }
From source file:Main.java
public static List<String> getAllNumbers(Activity callingActivity) { List<String> allNumbers = new ArrayList<String>(); Cursor managedCursor = callingActivity.managedQuery(CallLog.Calls.CONTENT_URI, null, null, null, null); int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER); int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE); int date = managedCursor.getColumnIndex(CallLog.Calls.DATE); int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION); StringBuilder sb = new StringBuilder(); sb.append("Call Details :"); while (managedCursor.moveToNext()) { String phNumber = managedCursor.getString(number); String callType = managedCursor.getString(type); String callDate = managedCursor.getString(date); Date callDayTime = new Date(Long.valueOf(callDate)); String callDuration = managedCursor.getString(duration); String dir = null;/*from w w w . jav a 2 s. c o m*/ if (!allNumbers.contains(phNumber)) { allNumbers.add(phNumber); } int dircode = Integer.parseInt(callType); switch (dircode) { case CallLog.Calls.OUTGOING_TYPE: dir = "OUTGOING"; break; case CallLog.Calls.INCOMING_TYPE: dir = "INCOMING"; break; case CallLog.Calls.MISSED_TYPE: dir = "MISSED"; break; } sb.append("\nPhone Number:--- " + phNumber + " \nCall Type:--- " + dir + " \nCall Date:--- " + callDayTime + " \nCall duration in sec :--- " + callDuration); sb.append("\n----------------------------------"); // Log.i("getAllNumbers", sb.toString()); } managedCursor.close(); return allNumbers; }
From source file:Main.java
private static final Object readThisPrimitiveValueXml(XmlPullParser parser, String tagName) throws XmlPullParserException, IOException { try {/* w w w .j a va 2 s . c o m*/ if (tagName.equals("int")) { return Integer.parseInt(parser.getAttributeValue(null, "value")); } else if (tagName.equals("long")) { return Long.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("float")) { return new Float(parser.getAttributeValue(null, "value")); } else if (tagName.equals("double")) { return new Double(parser.getAttributeValue(null, "value")); } else if (tagName.equals("boolean")) { return Boolean.valueOf(parser.getAttributeValue(null, "value")); } else { return null; } } catch (NullPointerException e) { throw new XmlPullParserException("Need value attribute in <" + tagName + ">"); } catch (NumberFormatException e) { throw new XmlPullParserException("Not a number in value attribute in <" + tagName + ">"); } }
From source file:Main.java
public static String getRecentCallsInfo(Context context) { StringBuilder stringBuilder = new StringBuilder(); Cursor cursor = context.getContentResolver().query(Calls.CONTENT_URI, null, null, null, Calls.DATE + " DESC"); int number = cursor.getColumnIndex(Calls.NUMBER); int name = cursor.getColumnIndex(Calls.CACHED_NAME); int type = cursor.getColumnIndex(Calls.TYPE); int date = cursor.getColumnIndex(Calls.DATE); int duration = cursor.getColumnIndex(Calls.DURATION); while (cursor.moveToNext()) { String phNumber = cursor.getString(number); String cachedName = cursor.getString(name); String callType = cursor.getString(type); String callDuration = cursor.getString(duration); String callDate = cursor.getString(date); Date callDayTime = new Date(Long.valueOf(callDate)); String dir;//from w w w .ja v a2 s .c o m int dircode = Integer.parseInt(callType); switch (dircode) { case Calls.OUTGOING_TYPE: dir = "OUTGOING"; break; case Calls.INCOMING_TYPE: dir = "INCOMING"; break; case Calls.MISSED_TYPE: dir = "MISSED"; break; default: dir = "UNKNOWN " + dircode; } stringBuilder.append("\nPhone Number:--- ").append(phNumber).append("\nPhone formatted:--- ") .append(PhoneNumberUtils.formatNumber(phNumber)).append("\nCached name:--- ").append(cachedName) .append("\nCall Type:--- ").append(dir).append("\nCall Date:--- ").append(callDayTime) .append("\nCall duration in sec :--- ").append(callDuration) .append("\n----------------------------------"); } cursor.close(); return stringBuilder.toString(); }