• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Validation

 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

I was using a SimpleDateFormat to validate if a Date was valid or not, I hoped that it will raise a ParseException in case that the format was not yyyy/MM/dd, but it seems that it allows weird dates as 2000/32/57 or 0/0/0, so I would like to know if I can ignore this (because is a bug found in this class) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6205670 and redo the date to get a valid one or should I validate the whole date,

What would you do ?
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulises Pulido:


What would you do ?


I didn't implement such thing, I just use String without do any validation.


Good Luck !!!

Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeffry Kristianto Yanuar:


I didn't implement such thing, I just use String without do any validation.


Good Luck !!!

Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)


But, that would mean that you can insert an invalid Date, isn't it ?

Also I have this on my assignment

"The new application, using the existing data file format, must allow the CSRs to generate a list of accomodations that match a customer's criteria"

Does that mean that I won't update or create new bookings just to search for criterias given by the user ?
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, in the user interface section answers what I asked.

"It must allow the user to book a selected record, updating the database file accordingly."

But that would mean that the user is only allowed to update the owner field, is that correct ?

If it is I assume that the other data would be shown as read only mode. and only have a text field where you can put the owner number which should be a long value.

Are my assumptions correct ?
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create my own interface that extends the DBMain interface and add 2 additional methods, book a room and search for room(s). When book a room it is a bad practice to use update method in the DBMain interface just for updating the customer who book the room, so I create my own interface.

Whenever you implement the validation or not, just document your assumption and the reason for doing so. If the spec doesn't say so, it means that you don't have to do that


Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
[ December 26, 2008: Message edited by: Jeffry Kristianto Yanuar ]
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this application, you won't need to create or delete records. However, you must entirely implement the interface that was provided to you. And also, your delete method must use the locking mechanism as well as your update method (note the comments of the lock method in the interface that was provided to you; it says that it locks a record so it can be updated or deleted).

You don't have to verify such thing (if a date is valid or not). But, just for curiosity, here's something I created sometime ago, to verify if a date is valid or not.



And yes, you only have to update the owner field of each record when booking a room. In my case, I have a bookRoom method in a class of the business/services layer, but it uses the update method of the DBMain interface implementation.
[ December 24, 2008: Message edited by: Roberto Perillo ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic