aspose file tools
The moose likes Performance and the fly likes Performance tuning in date validation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "Performance tuning in date validation" Watch "Performance tuning in date validation" New topic
Author

Performance tuning in date validation

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
I'm trying to read the udp port and process the message, at a fast rate. as per protocol, i should check if there is a timestamp in the beginning of the message. This timestamp should only be in a specific format (like Jan 10 10:00:00). If i dont find this timestamp, i have to insert one myself.
My problem is, as this should be done for every message, i dont know how efficiently i can do this. Is there an easier way to validate the timestamp? right now, ive only thought of 1 thing - take the 1st 3 tokens, check the 1st token against a list of strings like Jan, Feb... , check if the other numbers r within the correct range, etc.
Please give me any kind of performance tips related to this (not only related to the parsing logic, but also on which classes to use to get better performance etc.)


Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Have you looked at SimpleDateFormat?

you can also use the parse method to validate date structure( i.e. sdf.parse("Jan 10 10:00:00") will throw an exception if the format is wrong, otherwise it creates a java.util.Date )
Just another idea.
Jamie
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
Thanks very much. I'll knew about SimpleDateFormat, but wasnt aware of parse method. I'll look into it. thnx again.
 
 
subject: Performance tuning in date validation
 
Threads others viewed
caculating the difference between dates
converting sqldates?
problem about cxf and axis2
Syslog collection
Creating table inside div
MyEclipse, The Clear Choice