Java: 2 runtime errors I can't figure out
<p>I am working on a homework assignment, and I am going a little "above and beyond" what is called for by the assignment. I am getting a run-time error in my code, and can not for the life of me figure out what it is that I have done wrong.</p>

<p>Here is the assignment:</p>

<blockquote>
  <p>Write a program that displays a simulated paycheck. The program should ask the user to enter the date, the payee’s name, and the amount of the check. It should then display a simulated check with the dollar amount spelled out.</p>
</blockquote>

<p>Here is my code:</p>

<p>CheckWriter:</p>

<pre><code>/* CheckWriter.java */

// Imported Dependencies
import java.util.InputMismatchException;
import java.util.Scanner;

public class CheckWriter {
    public static void main(String args[]) {
        Scanner keyboard = new Scanner(System.in);

        // Try to get the name
        String name = "";
        NameValidator validateName = new NameValidator();
        while (validateName.validate(name) == false) {
            System.out.println("Enter the name: ");
            name = keyboard.nextLine();

            if (validateName.validate(name) == false) {
                System.out.println("Not a valid name.");
            }
        }

        // Get the date
        String date = "";
        DateValidator validateDate = new DateValidator();
        while (!validateDate.validate(date)) {
            System.out.println("Enter the date (dd/mm/yyyy): ");
            date = keyboard.nextLine();

            if (!validateDate.validate(date)) {
                System.out.println("Not a valid date.");
            }
        }

        // Try to get the amount of the check
        String checkAmount = "";
        CurrencyValidator validateCurrency = new CurrencyValidator();
        while (!validateCurrency.validate(checkAmount)) {

            System.out.print("Enter the Check Amount (XX.XX):  $");
            checkAmount = keyboard.nextLine();

            if (!validateCurrency.validate(checkAmount)) {
                System.out.println("Not a valid check amount.");
            }
        }

        String checkWords = checkToWords(checkAmount);  // ERROR! (48)

        System.out
        .println("------------------------------------------------------\n"
                + "Date: "
                + date
                + "\n"
                + "Pay to the Order of: "
                + name
                + "         $"
                + checkAmount
                + "\n"
                + checkWords
                + "\n"
                + "------------------------------------------------------\n");
    }

    private static String checkToWords(String checkAmount) {

        /**
         * Here I will use the string.split() method to separate out
         * the integer and decimal portions of the checkAmount.
         */

        String delimiter = "\\.\\$";
        /* Remove any commas from checkAmount */
        checkAmount.replace(",", "");
        /* Split the checkAmount string into an array */
        String[] splitAmount = checkAmount.split(delimiter);

        /* Convert the integer portion of checkAmount to words */
        NumberToWords intToWord = new NumberToWords();
        long intPortion = Long.parseLong(splitAmount[0]);       // ERROR! (84)
        intToWord.convert(intPortion);
        String intAmount = intToWord.getString() + " dollars";

        /* Convert the decimal portion of checkAmount to words */
        String decAmount = "";
        long decPortion = Long.parseLong(splitAmount[1]);
        if (decPortion != 0) {
            NumberToWords decToWord = new NumberToWords();
            decToWord.convert(Long.parseLong(splitAmount[1]));
            decAmount = " and " + decToWord.getString() + " cents.";

        }

        return (intAmount + decAmount);
    }
}
</code></pre>

<p>Note that I am using external class files to handle validation of the name, date, currency, and conversion from numbers to words.  These class files all work as intended.</p>

<p>The error I am getting is:</p>

<blockquote>
  <p>Exception in thread "main" java.lang.NumberFormatException: For input string: ""</p>

<pre><code>at java.lang.NumberFormatException.forInputString(Unknown Source)

at java.lang.Long.parseLong(Unknown Source)

at java.lang.Long.parseLong(Unknown Source)

at CheckWriter.checkToWords(CheckWriter.java:82)

at CheckWriter.main(CheckWriter.java:46)
</code></pre>
</blockquote>

<p>I have commented the lines in my code that are causing the errors that I am experiencing.</p>

<p>Could someone please assist me in figuring where my code is going wrong?  I can include the other class files if you feel that it would be needed.</p>

<p>EDIT:  When I run the code, it asks for the name and date.  Before asking for the check amount is when it throws the error.</p>

<p>EDIT 2:  A huge thank you to cotton.m!  Thanks to his advice, I have changed the while statements to look like this:</p>

<pre><code>while(!validateDate.validate(date) &amp;&amp; date == "")
</code></pre>

<p>This has now fixed my issue.  It would appear that when validating data with a regex expression, an empty string will return true.</p>
