Class RomanNumerals

java.lang.Object
com.globalmentor.text.RomanNumerals

public class RomanNumerals extends Object
Utilities for working with Roman numerals.

Integers are used to represent Roman numerals. As a Java integer is 32 bits long, a string would need over two million Roman numeral 'M's to surpass this limit.

Conversion algoritms inspired from "When in Rome...." by Jonathan Knudsen at http://java.oreilly.com/bite-size/java_0698.html.

Author:
Garret Wilson
See Also:
  • Constructor Details

    • RomanNumerals

      public RomanNumerals()
      Default constructor.
  • Method Details

    • getValue

      public static int getValue(char c)
      Returns the value of the given Roman numeral character.
      Parameters:
      c - The character containing a Roman numeral character.
      Returns:
      The value of the given Roman numeral character, or -1 if the character isn't recognized.
    • parseRomanNumerals

      public static int parseRomanNumerals(String romanNumerals)
      Parses the given Roman numerals and returns their integer value.
      Parameters:
      romanNumerals - The characters representing the Roman numerals.
      Returns:
      The value of the Roman numerals.
      Throws:
      NumberFormatException - Thrown if the given string does not contain a valid Roman numeral value.