Roman Numerals library for Java
If you need to convert numbers to Roman Numerals, or Roman Numerals to
numbers, then this library is for you.
Features
- Converts in both directions.
- Has strict and loose Roman numeral decoding options.
- High-performance: Can convert 100,000 numbers per second per core.
- Open Source -- AGPL license. Full source code and project
build files available.
- Commercial use-friendly -- commercial license available.
- Command-line conversion tool (examples below).
Maven Setup
To use the Roman Numerals library in your Maven project, simply add
the dependency and repository to your POM:
<dependencies>
<dependency>
<groupId>com.frequal.romannumerals</groupId>
<artifactId>roman-numerals</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>frequal.com</id>
<url>http://frequal.com/maven-repository</url>
</repository>
</repositories>
Download
API Examples
converter = new Converter();
// Convert Roman numerals to numbers
int convertedNumber = converter.toNumber("IV"));
// Convert numbers to Roman numerals
String romanNumerals = converter.toRomanNumerals(1999));
// Strict mode throws ParseExceptions on illegal numerals
strictConverter = new Converter(true);
strictConverter.toNumber("IM");
Command-line Examples
> java -jar roman-numerals-1.3.jar 3888
3888 in Roman numerals: MMMDCCCLXXXVIII
> java -jar roman-numerals-1.3.jar 6
6 in Roman numerals: VI
> java -jar roman-numerals-1.3.jar 9
9 in Roman numerals: IX
> java -jar roman-numerals-1.3.jar IX
IX as a number: 9
> java -jar roman-numerals-1.3.jar MMIV
MMIV as a number: 2004
Upcoming Features
- NumberFormat interface
- Additional strict checks
Last modified on 23 Feb 2013 by AO
Copyright © 2024 Andrew Oliver