Name: tradukisto
Owner: Allegro Tech
Description: A Java library created to convert numbers to their word representations
Created: 2015-03-30 09:29:42.0
Updated: 2018-05-16 12:39:01.0
Pushed: 2018-05-22 14:58:52.0
Size: 349
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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 which provides numbers conversion for the Polish language. There are many single 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.
Integer
to String
with numerical representation support.BigDecimal
to String
with money representation support.Add tradukisto
as dependency:
sitories {
mavenCentral()
ndencies {
compile 'pl.allegro.finance:tradukisto:1.3.0'
and use it:
eConverters converter = ValueConverters.ENGLISH_INTEGER;
ng valueAsWords = converter.asWords(1_234);
rtEquals("one thousand two hundred thirty-four", valueAsWords);
ava
yConverters converter = MoneyConverters.ENGLISH_BANKING_MONEY_VALUE;
ng moneyAsWords = converter.asWords(new BigDecimal("1234.56"));
rtEquals("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.
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.