Nice utils, Ted!  Thanks for sharing.

-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 31, 2003 12:07 PM
To: Struts Users Mailing List
Subject: Re: DateUtilities for ActionForms?


I started a helper class here:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/wqdata/wqdata/src/java/shared
/org_apache_commons/util/

(DateDisplay) which you might find helpful as a starting point.

It's mainly designed to help move dates back and forth between pulldown 
fields and/or calendar JavaScripts.

It doesn't have a locale field now, but it would be easy to add. Then you

As Mark mentioned, the Java classes do everything you need, so it's 
mainly a matter of wrapping them in a helper class tailored to your needs.

-Ted.


Mick Knutson wrote:
> OK, But my dates are international, and I do not know which of
> potentially several formats they may need to be in to support my fully 
> Internationalized application.
> 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","De
>> c"
>> };
>>   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]
> 
> 


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



---------------------------------------------------------------------
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]

Reply via email to