List of usage examples for java.lang Double longValue
public long longValue()
From source file:Main.java
public static void main(String[] args) { Double doubleObject = new Double("10.01"); long l = doubleObject.longValue(); System.out.println("long:" + l); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = Integer.valueOf(100); // Gets byte from Integer byte b = intObj.byteValue(); // Gets double from Integer double dd = intObj.doubleValue(); System.out.println("intObj = " + intObj); System.out.println("byte from intObj = " + b); System.out.println("double from intObj = " + dd); // Creates a Double object Double doubleObj = Double.valueOf("123.45"); // Gets different types of primitive values from Double double d = doubleObj.doubleValue(); float f = doubleObj.floatValue(); int i = doubleObj.intValue(); long l = doubleObj.longValue(); System.out.println("doubleObj = " + doubleObj); System.out.println("double from doubleObj = " + d); System.out.println("float from doubleObj = " + f); System.out.println("int from doubleObj = " + i); System.out.println("long from doubleObj = " + l); }
From source file:Main.java
public static long roundMillisToDate(double aMillis) { Double dateInMillis = Math.floor(aMillis / 86400000) * MILLIS_IN_DAY; return dateInMillis.longValue(); }
From source file:org.kuali.ole.sys.context.Log4jConfigurer.java
protected static long getReloadMillis() { String s = ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.LOG4J_RELOAD_MINUTES_KEY); try {//from w w w . j a va2 s. c om Double minutes = new Double(s); Double millis = minutes * MILLISECONDS_CONVERSION_MULTIPLIER; return millis.longValue(); } catch (NumberFormatException e) { throw new IllegalStateException("Could not parse '" + s + "'", e); } }
From source file:com.asprise.imaging.core.util.JsonUtils.java
public static Long toLong(Object object, Long defaultValue) { if (object == null) { return defaultValue; }//w w w . ja v a 2 s .co m if (object instanceof Number) { return ((Number) object).longValue(); } try { Double value = Double.valueOf(object.toString().trim()); return value.longValue(); } catch (NumberFormatException e) { return defaultValue; } }
From source file:org.sonar.batch.qualitygate.ConditionUtils.java
private static Comparable<Long> parseLong(ResolvedCondition condition, Measure measure) { Double value = getValue(condition, measure); return value != null ? value.longValue() : null; }
From source file:com.asprise.imaging.core.scan.twain.TwainUtil.java
/** * Extract the value represented by the given object (Number or String). * @param object the object to extract value from * @param defaultValue default value to be returned if object is null or {@linkplain NumberFormatException}. * @return the value extracted or default value if failed to extract the value. *//*w w w .ja va2 s. co m*/ public static long toLong(Object object, long defaultValue) { if (object == null) { return defaultValue; } if (object instanceof Number) { return ((Number) object).longValue(); } try { Double value = Double.valueOf(object.toString().trim()); return value.longValue(); } catch (NumberFormatException e) { return defaultValue; } }
From source file:Main.java
public static Long stringToLong(String str) { if (str == null) { return null; } else {// ww w. j a va 2 s .c o m try { return Long.parseLong(str); } catch (NumberFormatException e) { try { Double d = Double.valueOf(str); if (d.doubleValue() > mMaxLong.doubleValue() + 1.0) { Log.w(TAG, "Value " + d + " too large for long"); return null; } return Long.valueOf(d.longValue()); } catch (NumberFormatException nfe2) { Log.w(TAG, "Unable to interpret value " + str + " in field being " + "converted to long, caught NumberFormatException <" + nfe2.getMessage() + "> field discarded"); return null; } } } }
From source file:org.sonar.api.measures.MeasureUtils.java
public static Long getVariationAsLong(Measure measure, int periodIndex, Long defaultValue) { Double result = null; if (measure != null) { result = measure.getVariation(periodIndex); }/*from w ww. j a v a 2 s. co m*/ return result == null ? defaultValue : Long.valueOf(result.longValue()); }
From source file:org.sonar.server.computation.measure.BestValueOptimization.java
private static boolean isBestValue(Measure measure, Double bestValue) { switch (measure.getValueType()) { case BOOLEAN: return bestValue.intValue() == 1 ? measure.getBooleanValue() : !measure.getBooleanValue(); case INT://from www . ja v a 2 s .com return bestValue.intValue() == measure.getIntValue(); case LONG: return bestValue.longValue() == measure.getLongValue(); case DOUBLE: return bestValue.compareTo(measure.getDoubleValue()) == 0; default: return false; } }