List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:Main.java
public static long betweenMilli1(String t1, String t2, String... patterns) { if (patterns != null && patterns.length > 0) { return getDate(t1, patterns[0]).getTime() - getDate(t2, patterns.length > 1 ? patterns[1] : patterns[0]).getTime(); }//from w ww . j av a 2s . c o m return Long.MIN_VALUE; }
From source file:Main.java
public static boolean isLikelyDouble(long value) { // Check for some common named double values // We don't check for Double.MIN_VALUE, which has a long representation of 1 if (value == canonicalDoubleNaN || value == maxDouble || value == piDouble || value == eDouble) { return true; }//w ww . j a va2s . c o m // Check for some named long values if (value == Long.MAX_VALUE || value == Long.MIN_VALUE) { return false; } // a non-canocical NaN is more likely to be an long double doubleValue = Double.longBitsToDouble(value); if (Double.isNaN(doubleValue)) { return false; } // Otherwise, whichever has a shorter scientific notation representation is more likely. // Long wins the tie String asLong = format.format(value); String asDouble = format.format(doubleValue); // try to strip off any small imprecision near the end of the mantissa int decimalPoint = asDouble.indexOf('.'); int exponent = asDouble.indexOf("E"); int zeros = asDouble.indexOf("000"); if (zeros > decimalPoint && zeros < exponent) { asDouble = asDouble.substring(0, zeros) + asDouble.substring(exponent); } else { int nines = asDouble.indexOf("999"); if (nines > decimalPoint && nines < exponent) { asDouble = asDouble.substring(0, nines) + asDouble.substring(exponent); } } return asDouble.length() < asLong.length(); }
From source file:Main.java
private static long betweenTime(int what, String t1, String t2, String... patterns) { if (patterns.length == 0) { throw new RuntimeException("must give me a pattern"); }/*from www . ja va 2s . com*/ Date d1 = getDate(t1, patterns[0]); Date d2 = getDate(t2, patterns.length > 1 ? patterns[1] : patterns[0]); if (d1 != null && d2 != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(d1); int i1 = calendar.get(what); calendar.setTime(d2); int i2 = calendar.get(what); return i1 - i2; } return Long.MIN_VALUE; }
From source file:Main.java
/** * Subtract two long integers, checking for overflow. * //from www .java 2 s . c om * @param a first value * @param b second value * @return the difference <code>a-b</code> * @throws ArithmeticException if the result can not be represented as an * long * @since 1.2 */ public static long subAndCheck(long a, long b) { long ret; String msg = "overflow: subtract"; if (b == Long.MIN_VALUE) { if (a < 0) { ret = a - b; } else { throw new ArithmeticException(msg); } } else { // use additive inverse ret = addAndCheck(a, -b, msg); } return ret; }
From source file:annis.utils.Utils.java
public static String max(List<Long> runtimeList) { long max = Long.MIN_VALUE; for (long value : runtimeList) { max = Math.max(max, value); }//w w w . jav a 2 s . com return String.valueOf(max); }
From source file:com.amalto.core.history.action.NoOpAction.java
private NoOpAction() { this(Long.MIN_VALUE); }
From source file:br.com.blackhubos.eventozero.updater.assets.uploader.Uploader.java
@SuppressWarnings("unchecked") public static Optional<Uploader> parseJsonObject(JSONObject parse, MultiTypeFormatter formatter) { long id = Long.MIN_VALUE; String name = null;/*from w w w.j a v a 2 s.com*/ boolean admin = false; // Loop em todas entradas do JSON for (Map.Entry entries : (Set<Map.Entry>) parse.entrySet()) { Object key = entries.getKey(); Object value = entries.getValue(); String valueString = String.valueOf(value); /** Transforma o objeto em um {@link AssetUploaderInput) para usar com switch **/ switch (AssetUploaderInput.parseObject(key)) { case ADMIN: { // Obtem o valor que indica se quem enviou era administrador if (formatter.canFormat(Boolean.class)) { Optional<Boolean> result = formatter.format(value, Boolean.class); if (result.isPresent()) admin = result.get(); } break; } case ID: { // Obtm o ID do usurio id = Long.parseLong(valueString); break; } case LOGIN: { // Obtm o nome/login do usurio name = valueString; break; } default: { break; } } } if (id == Long.MIN_VALUE || name == null) { return Optional.empty(); } return Optional.of(new Uploader(name, admin, id)); }
From source file:com.linkedin.pinot.controller.utils.SegmentMetadataMockUtils.java
public static SegmentMetadata mockSegmentMetadata(String tableName, String segmentName, int numTotalDocs, String crc) {//from www .j ava 2 s . c o m SegmentMetadata segmentMetadata = Mockito.mock(SegmentMetadata.class); Mockito.when(segmentMetadata.getTableName()).thenReturn(tableName); Mockito.when(segmentMetadata.getName()).thenReturn(segmentName); Mockito.when(segmentMetadata.getTotalDocs()).thenReturn(numTotalDocs); Mockito.when(segmentMetadata.getTotalRawDocs()).thenReturn(numTotalDocs); Mockito.when(segmentMetadata.getCrc()).thenReturn(crc); Mockito.when(segmentMetadata.getPushTime()).thenReturn(Long.MIN_VALUE); Mockito.when(segmentMetadata.getRefreshTime()).thenReturn(Long.MIN_VALUE); return segmentMetadata; }
From source file:Main.java
/** * Multiply two long integers, checking for overflow. * /* w w w.j a va2 s.c o m*/ * @param a first value * @param b second value * @return the product <code>a * b</code> * @throws ArithmeticException if the result can not be represented as an * long * @since 1.2 */ public static long mulAndCheck(long a, long b) { long ret; String msg = "overflow: multiply"; if (a > b) { // use symmetry to reduce boundry cases ret = mulAndCheck(b, a); } else { if (a < 0) { if (b < 0) { // check for positive overflow with negative a, negative b if (a >= Long.MAX_VALUE / b) { ret = a * b; } else { throw new ArithmeticException(msg); } } else if (b > 0) { // check for negative overflow with negative a, positive b if (Long.MIN_VALUE / b <= a) { ret = a * b; } else { throw new ArithmeticException(msg); } } else { // assert b == 0 ret = 0; } } else if (a > 0) { // assert a > 0 // assert b > 0 // check for positive overflow with positive a, positive b if (a <= Long.MAX_VALUE / b) { ret = a * b; } else { throw new ArithmeticException(msg); } } else { // assert a == 0 ret = 0; } } return ret; }
From source file:io.galeb.core.entity.RuleOrder.java
public RuleOrder() { this(Long.MIN_VALUE, Integer.MIN_VALUE); }