@Test public void cardinalTest() { Assert.assertEquals("sıfır", TurkishNumbers.convertToString(0)); Assert.assertEquals("bin", TurkishNumbers.convertToString(1000)); Assert.assertEquals("bir", TurkishNumbers.convertToString(1)); Assert.assertEquals("on bir", TurkishNumbers.convertToString(11)); Assert.assertEquals("yüz on bir", TurkishNumbers.convertToString(111)); Assert.assertEquals("yüz on bir bin", TurkishNumbers.convertToString(111000)); Assert.assertEquals( "bir milyon iki yüz otuz dört bin beş yüz altmış yedi", TurkishNumbers.convertToString(1_234_567)); Assert.assertEquals( "bir milyar iki yüz otuz dört milyon beş yüz altmış yedi bin sekiz yüz doksan", TurkishNumbers.convertToString(1_234_567_890)); }
public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (girisPos % 1000); if (uclu != 0) { if (uclu == 1 && sayac == 1) { result = thousands[sayac] + " " + result; } else { result = convertThreeDigit(uclu) + " " + thousands[sayac] + " " + result; } } sayac++; girisPos /= 1000; } if (input < 0) { return "eksi " + result.trim(); } else { return result.trim(); } }
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (girisPos % 1000); if (uclu != 0) { if (uclu == 1 && sayac == 1) { result = thousands[sayac] + " " + result; } else { result = convertThreeDigit(uclu) + " " + thousands[sayac] + " " + result; } } sayac++; girisPos /= 1000; } if (input < 0) { return "eksi " + result.trim(); } else { return result.trim(); } } }
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (girisPos % 1000); if (uclu != 0) { if (uclu == 1 && sayac == 1) { result = thousands[sayac] + " " + result; } else { result = convertThreeDigit(uclu) + " " + thousands[sayac] + " " + result; } } sayac++; girisPos /= 1000; } if (input < 0) { return "eksi " + result.trim(); } else { return result.trim(); } }  }
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (girisPos % 1000); if (uclu != 0) { if (uclu == 1 && sayac == 1) { result = thousands[sayac] + " " + result; } else { result = convertThreeDigit(uclu) + " " + thousands[sayac] + " " + result; } } sayac++; girisPos /= 1000; } if (input < 0) { return "eksi " + result.trim(); } else { return result.trim(); } }  static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> replaceNumberStrings(List<String> inputSequence); static List<String> seperateConnectedNumbers(List<String> inputSequence); static List<String> seperateConnectedNumbers(String input); static long convertToNumber(String... words); static long convertToNumber(String text); static String convertOrdinalNumberString(String input); static List<String> separateNumbers(String s); static String getOrdinal(String input); static boolean hasNumber(String s); static boolean hasOnlyNumber(String s); static int romanToDecimal(String s); }
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (girisPos % 1000); if (uclu != 0) { if (uclu == 1 && sayac == 1) { result = thousands[sayac] + " " + result; } else { result = convertThreeDigit(uclu) + " " + thousands[sayac] + " " + result; } } sayac++; girisPos /= 1000; } if (input < 0) { return "eksi " + result.trim(); } else { return result.trim(); } }  static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> replaceNumberStrings(List<String> inputSequence); static List<String> seperateConnectedNumbers(List<String> inputSequence); static List<String> seperateConnectedNumbers(String input); static long convertToNumber(String... words); static long convertToNumber(String text); static String convertOrdinalNumberString(String input); static List<String> separateNumbers(String s); static String getOrdinal(String input); static boolean hasNumber(String s); static boolean hasOnlyNumber(String s); static int romanToDecimal(String s); static final long MAX_NUMBER; static final long MIN_NUMBER; }