@Test public void testMixedNumberWordToLong() throws ParsingException { assertEquals(10, Utils.mixedNumberWordToLong("10")); assertEquals(10.5e3, Utils.mixedNumberWordToLong("10.5K"), 0.0); assertEquals(10.5e6, Utils.mixedNumberWordToLong("10.5M"), 0.0); assertEquals(10.5e6, Utils.mixedNumberWordToLong("10,5M"), 0.0); assertEquals(1.5e9, Utils.mixedNumberWordToLong("1,5B"), 0.0); }
public static long mixedNumberWordToLong(String numberWord) throws NumberFormatException, ParsingException { String multiplier = ""; try { multiplier = Parser.matchGroup("[\\d]+([\\.,][\\d]+)?([KMBkmb])+", numberWord, 2); } catch (ParsingException ignored) { } double count = Double.parseDouble(Parser.matchGroup1("([\\d]+([\\.,][\\d]+)?)", numberWord) .replace(",", ".")); switch (multiplier.toUpperCase()) { case "K": return (long) (count * 1e3); case "M": return (long) (count * 1e6); case "B": return (long) (count * 1e9); default: return (long) (count); } }
Utils { public static long mixedNumberWordToLong(String numberWord) throws NumberFormatException, ParsingException { String multiplier = ""; try { multiplier = Parser.matchGroup("[\\d]+([\\.,][\\d]+)?([KMBkmb])+", numberWord, 2); } catch (ParsingException ignored) { } double count = Double.parseDouble(Parser.matchGroup1("([\\d]+([\\.,][\\d]+)?)", numberWord) .replace(",", ".")); switch (multiplier.toUpperCase()) { case "K": return (long) (count * 1e3); case "M": return (long) (count * 1e6); case "B": return (long) (count * 1e9); default: return (long) (count); } } }
Utils { public static long mixedNumberWordToLong(String numberWord) throws NumberFormatException, ParsingException { String multiplier = ""; try { multiplier = Parser.matchGroup("[\\d]+([\\.,][\\d]+)?([KMBkmb])+", numberWord, 2); } catch (ParsingException ignored) { } double count = Double.parseDouble(Parser.matchGroup1("([\\d]+([\\.,][\\d]+)?)", numberWord) .replace(",", ".")); switch (multiplier.toUpperCase()) { case "K": return (long) (count * 1e3); case "M": return (long) (count * 1e6); case "B": return (long) (count * 1e9); default: return (long) (count); } } private  Utils(); }
Utils { public static long mixedNumberWordToLong(String numberWord) throws NumberFormatException, ParsingException { String multiplier = ""; try { multiplier = Parser.matchGroup("[\\d]+([\\.,][\\d]+)?([KMBkmb])+", numberWord, 2); } catch (ParsingException ignored) { } double count = Double.parseDouble(Parser.matchGroup1("([\\d]+([\\.,][\\d]+)?)", numberWord) .replace(",", ".")); switch (multiplier.toUpperCase()) { case "K": return (long) (count * 1e3); case "M": return (long) (count * 1e6); case "B": return (long) (count * 1e9); default: return (long) (count); } } private  Utils(); static String removeNonDigitCharacters(String toRemove); static long mixedNumberWordToLong(String numberWord); static void checkUrl(String pattern, String url); static void printErrors(List<Throwable> errors); static String replaceHttpWithHttps(final String url); static String getQueryValue(URL url, String parameterName); static URL stringToURL(String url); static boolean isHTTP(URL url); static String removeUTF8BOM(String s); static String getBaseUrl(String url); static boolean isNullOrEmpty(final String str); static boolean isNullOrEmpty(final Collection<?> collection); static boolean isNullOrEmpty(final Map map); static boolean isWhitespace(final int c); static boolean isBlank(final String string); static String join(final CharSequence delimiter, final Iterable<? extends CharSequence> elements); }
Utils { public static long mixedNumberWordToLong(String numberWord) throws NumberFormatException, ParsingException { String multiplier = ""; try { multiplier = Parser.matchGroup("[\\d]+([\\.,][\\d]+)?([KMBkmb])+", numberWord, 2); } catch (ParsingException ignored) { } double count = Double.parseDouble(Parser.matchGroup1("([\\d]+([\\.,][\\d]+)?)", numberWord) .replace(",", ".")); switch (multiplier.toUpperCase()) { case "K": return (long) (count * 1e3); case "M": return (long) (count * 1e6); case "B": return (long) (count * 1e9); default: return (long) (count); } } private  Utils(); static String removeNonDigitCharacters(String toRemove); static long mixedNumberWordToLong(String numberWord); static void checkUrl(String pattern, String url); static void printErrors(List<Throwable> errors); static String replaceHttpWithHttps(final String url); static String getQueryValue(URL url, String parameterName); static URL stringToURL(String url); static boolean isHTTP(URL url); static String removeUTF8BOM(String s); static String getBaseUrl(String url); static boolean isNullOrEmpty(final String str); static boolean isNullOrEmpty(final Collection<?> collection); static boolean isNullOrEmpty(final Map map); static boolean isWhitespace(final int c); static boolean isBlank(final String string); static String join(final CharSequence delimiter, final Iterable<? extends CharSequence> elements); static final String HTTP; static final String HTTPS; }