pl.allegro.finance.tradukisto.internal.support.NumberChunking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tradukisto Show documentation
Show all versions of tradukisto Show documentation
Small java library created to convert numbers to their word representations
package pl.allegro.finance.tradukisto.internal.support;
import java.util.LinkedList;
import java.util.List;
public class NumberChunking {
static final int SPLIT_FACTOR = 1_000;
public List chunk(Long value) {
LinkedList result = new LinkedList<>();
while (value > 0) {
result.addFirst((int) (value % SPLIT_FACTOR));
value /= SPLIT_FACTOR;
}
return result;
}
}