@Test public void testValToLong() throws Exception { assertEquals(Long.valueOf(0L), SearchUtil.valToLong("0", 2)); assertEquals(Long.valueOf(100000000000000L), SearchUtil.valToLong("1000000000000", 2)); assertEquals(Long.valueOf(10000000L), SearchUtil.valToLong("100000", 2)); assertEquals(Long.valueOf(100000L), SearchUtil.valToLong("1000", 2)); assertEquals(Long.valueOf(100), SearchUtil.valToLong("1", 2)); assertEquals(Long.valueOf(133), SearchUtil.valToLong("1.33", 2)); assertEquals(Long.valueOf(3210), SearchUtil.valToLong("32.1", 2)); assertEquals(Long.valueOf(12), SearchUtil.valToLong(".12", 2)); assertEquals(Long.valueOf(9800), SearchUtil.valToLong("98", 2)); assertEquals(Long.valueOf(9822), SearchUtil.valToLong("98.222", 2)); assertEquals(Long.valueOf(9856), SearchUtil.valToLong("98.555", 2)); assertNull(SearchUtil.valToLong("98.555zzz", 2)); }
public static Long valToLong(final String value, final int scale) { try { final BigDecimal decimal = new BigDecimal(value); return decimal.movePointRight(scale).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } catch (Exception exp) { } return null; }
SearchUtil { public static Long valToLong(final String value, final int scale) { try { final BigDecimal decimal = new BigDecimal(value); return decimal.movePointRight(scale).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } catch (Exception exp) { } return null; } }
SearchUtil { public static Long valToLong(final String value, final int scale) { try { final BigDecimal decimal = new BigDecimal(value); return decimal.movePointRight(scale).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } catch (Exception exp) { } return null; }  }
SearchUtil { public static Long valToLong(final String value, final int scale) { try { final BigDecimal decimal = new BigDecimal(value); return decimal.movePointRight(scale).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } catch (Exception exp) { } return null; }  static List<String> splitForSearch(final String phrase, final int charThreshold); static String priceFacetName(final long shopId, final String currency); static long priceToLong(final BigDecimal price); static Long valToLong(final String value, final int scale); static String longToVal(final String value, final int scale); static void destroy(); static void addDestroyable(final Destroyable destroyable); }
SearchUtil { public static Long valToLong(final String value, final int scale) { try { final BigDecimal decimal = new BigDecimal(value); return decimal.movePointRight(scale).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } catch (Exception exp) { } return null; }  static List<String> splitForSearch(final String phrase, final int charThreshold); static String priceFacetName(final long shopId, final String currency); static long priceToLong(final BigDecimal price); static Long valToLong(final String value, final int scale); static String longToVal(final String value, final int scale); static void destroy(); static void addDestroyable(final Destroyable destroyable);  }