Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 11th, 2006, 11:08 AM   #1
Konnor
Newbie
 
Join Date: Aug 2005
Posts: 22
Rep Power: 0 Konnor is on a distinguished road
Error handling inputs

What would you guys recommend as being the best way to error handle precise inputs?

for example my program ask the user for a date, which must be of the form '2006-03-11' (yyyy-mm-dd)

it also asks for a location and destination. Is there anyways I can check for dodgy inputs such as 'asadsddddddewrew'

Many thanks,
Konnor is offline   Reply With Quote
Old Mar 11th, 2006, 12:06 PM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
What kind of user interface do you have? Console? Swing? Either way, for the date, I'd suggest taking a look at the DateFormat class. For the other inputs, it depends on if you have a known set of locations or if the user can input anywhere they want (like Ulaanbaatar, or Ouagadougou).
Jimbo is offline   Reply With Quote
Old Mar 11th, 2006, 6:12 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
ROFL, Jimbo! You made me Google those! Ulaanbaatar is my favorite, I'm goin' if it's the last thing I do!
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 11th, 2006, 6:24 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
SimpleDateFormat would seem to be the class to use for parsing dates.
Arevos is offline   Reply With Quote
Old Mar 11th, 2006, 10:43 PM   #5
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
Quote:
Originally Posted by DaWei
ROFL, Jimbo! You made me Google those! Ulaanbaatar is my favorite, I'm goin' if it's the last thing I do!
I had to look up the actual spellings on Wikipedia, couldnt remember exactly what they were...
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC