I am not sure whats wrong here. This is a simple event handling program we are trying to make for a group assignment, but it throws an exception if the name entered is more than one word.
/* Team C Prototype EventTrack * Wednesday, October 19, 2011 * Get Event Name * Get Start Time * */ import java.util.Scanner; import java.util.Calendar; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class EventTrack2 { public static void main (String[] args) { Boolean bErrorCode = true; //**if error in EventTrack will return and give user another chance while (bErrorCode == true) { bErrorCode = EventInput(); } } public static Boolean EventInput() { Boolean bEventInput = false; int iComplete; int iTimeInput; int iYear; int iMonth; int iDay; int iHour; int iMinute; String sEventName; String sDateInput=""; String sStartDate=""; String sStartTime=""; String sEndDate=""; String sEndTime=""; int iLength=0; DateFormat dateFormat; Date dInput; long lMillisecondsStart; long lMillisecondsEnd; long lDiff; long lDiffMinutes; long lDiffHours; Calendar startDate = Calendar.getInstance(); //**Calendar instance start Calendar endDate = Calendar.getInstance(); //**Calendar instance end Scanner sc = new Scanner(System.in); System.out.println("*****************"); System.out.print("Enter Event Name: "); sEventName = sc.next(); //**Put Event Name in string iLength = sEventName.length(); if ( iLength < 1){ System.out.println("*****************"); System.out.print("Event Name can not be null, Enter Event Name: "); sEventName = sc.nextLine(); } try { System.out.println("*****************"); System.out.print("Enter Start Date MM/DD/YYYY: "); sDateInput = sc.next(); //**Put Start Date in string dateFormat = new SimpleDateFormat("MM/dd/yyyy"); dInput = (Date)dateFormat.parse(sDateInput); startDate.setTime(dInput); } catch (Exception ex) { System.out.println("Exception in getting Start Date occurred"); bEventInput = true; } try { System.out.println("*****************"); System.out.print("Enter Start Hour 1 to 24:"); iTimeInput = sc.nextInt(); //**Put Start Hour if (iTimeInput >= 0 || iTimeInput <= 24) { startDate.set(Calendar.HOUR_OF_DAY, iTimeInput); } else { System.out.println("*****************"); System.out.print("Enter Start Hour 1 to 24:"); iTimeInput = sc.nextInt(); //**Put Start Hour if (iTimeInput >= 0 || iTimeInput <= 24) { startDate.set(Calendar.HOUR_OF_DAY, iTimeInput); } else { startDate.set(Calendar.HOUR_OF_DAY, 12); } } System.out.println("*****************"); System.out.print("Enter Start Minute 0 to 60:"); iTimeInput = sc.nextInt(); //**Put Start Minute if (iTimeInput >= 0 || iTimeInput <= 60) { startDate.set(Calendar.MINUTE, iTimeInput); } else { System.out.println("*****************"); System.out.print("Enter Start Minute 0 to 60:"); iTimeInput = sc.nextInt(); //**Put Start Hour if (iTimeInput >= 0 || iTimeInput <= 24) { startDate.set(Calendar.MINUTE, iTimeInput); } else { startDate.set(Calendar.MINUTE, 0); } } } catch (Exception ex) { System.out.println("Exception in getting Start Time occurred"); bEventInput = true; } try { System.out.println("*****************"); System.out.print("Enter End Date MM/DD/YYYY: "); sDateInput = sc.next(); //**Put End Date in string dateFormat = new SimpleDateFormat("MM/dd/yyyy"); dInput = (Date)dateFormat.parse(sDateInput); endDate.setTime(dInput); } catch (Exception ex) { System.out.println("Exception in getting Start Date occurred"); bEventInput = true; } try { System.out.println("*****************"); System.out.print("Enter End Hour 1 to 24:"); iTimeInput = sc.nextInt(); //**Put End Hour if (iTimeInput >= 0 || iTimeInput <= 24) { endDate.set(Calendar.HOUR_OF_DAY, iTimeInput); } else { System.out.println("*****************"); System.out.print("Enter End Hour 1 to 24:"); iTimeInput = sc.nextInt(); //**Put End Hour if (iTimeInput >= 0 || iTimeInput <= 24) { endDate.set(Calendar.HOUR_OF_DAY, iTimeInput); } else { endDate.set(Calendar.HOUR_OF_DAY, 12); } } System.out.println("*****************"); System.out.print("Enter End Minute 0 to 60:"); iTimeInput = sc.nextInt(); //**Put End Minute if (iTimeInput >= 0 || iTimeInput <= 60) { endDate.set(Calendar.MINUTE, iTimeInput); } else { System.out.println("*****************"); System.out.print("Enter End Minute 0 to 60:"); iTimeInput = sc.nextInt(); //**Put End Minute if (iTimeInput >= 0 || iTimeInput <= 24) { endDate.set(Calendar.MINUTE, iTimeInput); } else { endDate.set(Calendar.MINUTE, 0); } } } catch (Exception ex) { System.out.println("Exception in getting End Time occurred"); bEventInput = true; } lMillisecondsStart = startDate.getTimeInMillis(); lMillisecondsEnd = endDate.getTimeInMillis(); lDiff = lMillisecondsEnd - lMillisecondsStart; lDiffMinutes = lDiff / (60 * 1000); lDiffHours = lDiff / (60 * 60 * 1000); dateFormat = new SimpleDateFormat("MM/dd/yyyy"); sStartDate = dateFormat.format(startDate.getTime()); sEndDate = dateFormat.format(endDate.getTime()); System.out.println("*****************"); System.out.println("Don't Forget about " + sEventName + "!"); System.out.println("*****************"); System.out.println("Begins on:" + sStartDate); System.out.println("Ends on:" + sEndDate); System.out.println("Runs for:" + lDiffMinutes + " minutes"); System.out.println("*****************"); System.out.println(" "); sStartTime = startDate.get(Calendar.HOUR) + ":" + startDate.get(Calendar.MINUTE) + ":" + startDate.get(Calendar.SECOND); System.out.println("Be there at: " + sStartTime); sEndTime = endDate.get(Calendar.HOUR) + ":" + endDate.get(Calendar.MINUTE) + ":" + endDate.get(Calendar.SECOND); System.out.println("Leave at: " + sEndTime); System.out.println("This will be " + lDiffHours + " hours of fun! Hope to see your there!"); System.out.println(" "); return bEventInput = false; } }