Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smart Java Date Parsing



On Apr 30, 2007, at 6:31 PM, Jeff Martin wrote:

Does anyone know of a class or library that does "smart" date parsing ("guessing" would be a better word)?

What I did was to have an array of java.text.SimpleDateFormat where each array element contained a different possible pattern of a date. I then iterated over the array until one parsed successfully, i.e.:


	for ( SimpleDateFormat format : dateFormats )
	    try {
	        return format.parse( s );
	    }
	    catch ( ParseException e ) {
	        // ignore
	    }
	throw new IllegalArgumentException();

- Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Pressing a button during main (From: Doug Zwick <email@hidden>)
 >Smart Java Date Parsing (From: Jeff Martin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.