Such as the use of "Jan, Feb...etc..." would never work in this context.
--- Thanks... Mick Knutson ---
From: "Mark Galbreath" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Subject: RE: DateUtilities for ActionForms? Date: Fri, 30 May 2003 09:18:18 -0400
I wrote a simple conversion method and pass the Strings through - no hassle at all. Given the String "Jan 1, 2003":
Calendar date = getDate( string );
private Calendar getDate( String string ) { Calender cal = Calender.getInstance(); String formatted_date = null; String[] months = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; StringTokenizer st = new StringTokenizer( string ); String str = st.nextToken();
for( int i; i < months.length; i++ ) {
if( str.equalsIgnoreCase( months[ i ] )) { month = i; break; } }
String temp = st.nextToken(); StringTokenizer token = new StringTokenizer( temp, "," ); date = ( new Integer(( String ) token.nextElement() )).intValue(); year = ( new Integer(( String ) st.nextElement() )).intValue();
return( cal.set( year, month + 1, date )); }
Easy, heh? You could also use regular expressions if you are using JDK 1.4.
Mark
-----Original Message----- From: Mick Knutson [mailto:[EMAIL PROTECTED] Sent: Friday, May 30, 2003 4:09 AM To: [EMAIL PROTECTED] Subject: DateUtilities for ActionForms?
Is there already a set of DateUtilities for ActionForms? I am finding myself converting to and from Strings and also reformating my Dates to and from my DB.
I am using EntityBeans and ValueObjects with my ActionForms, so to keep the types in synch, it seems I have to do serious conversion all the time. Thanks in advance for the help.
--- Thanks... Mick Knutson ---
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]