wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes How to check if date/time was entered? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to check if date/time was entered?" Watch "How to check if date/time was entered?" New topic

How to check if date/time was entered?

Kerry Shannon
Ranch Hand

Joined: May 08, 2001
Posts: 31
How can you verify that a date / time was entered in a field? We tried to convert the time into a long, and then check if null, but it doesn't like that.
starttime = time.getDStartTime().getTime();
if (starttime == null)
starttime = 0;
What do you need to convert the time to before checking (String?), or what can you use to check a long?
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Use the DateFormat parse(String) method. It will throw an exception if the string is not a valid date.
I agree. Here's the link: http://aspose.com/file-tools
subject: How to check if date/time was entered?
Similar Threads
How to convert Long Time to Time/Date
Comparing two times
basic concept level question regarding threads
Web Service Request-Response Association
[SOLVED] Is it my math or my logic/code? Number Formatting difficulties