A Java library created to convert numbers to their word representations
Clone or download
Latest commit b5f7dad Sep 18, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config/checkstyle upgrading gradle Sep 3, 2017
gradle/wrapper gradle update Mar 26, 2018
src Removed unused import Jul 12, 2018
.gitignore Merge branch 'master' into master Mar 26, 2018
.travis.yml bring java9 support back Feb 2, 2018
CHANGELOG.md Preparing for release Sep 18, 2018
LICENSE.rst Initial commit Apr 1, 2015
README.md Preparing for release Sep 18, 2018
build.gradle gradle update Mar 26, 2018
gradlew upgrading gradle Sep 3, 2017
gradlew.bat upgrading gradle Sep 3, 2017
settings.gradle Initial commit Apr 1, 2015

README.md

Tradukisto

Build Status Coverage Status Maven Central

Tradukisto is a library for Java 8+ created to convert numbers to their word representations.

The main motivation behind its creation was lack of a production-ready tool providing number conversion for Polish language. There are many individual classes, but we felt there is definitely space for something well tested and ready to use in production without copy-pasting someone else's code.

Features

  • Converts Integer to String with numerical representation support.
  • Converts BigDecimal to String with money representation support.

Supported languages

  • Brazilian Portuguese
  • Czech
  • English
  • French
  • German
  • Kazakh
  • Latvian
  • Polish
  • Russian
  • Slovak
  • Ukrainian

Usage

Add tradukisto as dependency:

repositories {
    mavenCentral()
}

dependencies {
    compile 'pl.allegro.finance:tradukisto:1.5.0'
}

and use it:

ValueConverters converter = ValueConverters.ENGLISH_INTEGER;
String valueAsWords = converter.asWords(1_234);

assertEquals("one thousand two hundred thirty-four", valueAsWords);
MoneyConverters converter = MoneyConverters.ENGLISH_BANKING_MONEY_VALUE;
String moneyAsWords = converter.asWords(new BigDecimal("1234.56"));

assertEquals("one thousand two hundred thirty-four £ 56/100", moneyAsWords);

Tradukisto can handle only values with no more than two digits after the decimal point. Otherwise IllegalArgumentException will be thrown. For that reason you should either construct BigDecimal object based on String value as shown in example above or use setScale method to ensure that given value has appropriate precision.

License

Copyright 2015-2018 Allegro Group

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.