• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need a Program  RSS feed

 
Sridhar Ranganthan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I hhave string array, In that i need to identify this string/date ,

example :a[0]="abcd";
a[1]="07/02/2008";

Thanks,
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the java.text.SimpleDateFormat class. If you don't get a ParseException, then it is a date string in the specified format.

Henry
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:If you don't get a ParseException, then it is a date string in the specified format.

Or use the parse method that takes a ParsePosition; that returns null on failure:
This is also used inside the parse method that throws a ParseException:
Sun just uses the ParsePosition instead of the result to check for an error, but it's essentially the same.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!