A robust starter web application to ease Java webapp development.

Home | Tutorials | Demos | Issues

Convert Date attributes to JalaliDate

View: New views
4 Messages — Rating Filter:   Alert me  

Convert Date attributes to JalaliDate

by alibehzadian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

I am developing a Persian-language site with AppFuse Struts 2 Archetype.
In web tier, users enter Jalali date but I want to convert these jalali dates
to Gregorian date (java.util.Date) before saving them in database.

I have the algorithm and libraries to for conversion. Which classes should I
modify in AppFuse?

Thanks,
Ali Behzadian Nejad.

Re: Convert Date attributes to JalaliDate

by pedro_burglin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ali,

If you just want to convert the dates in the Data Access Object layer I think you just need to translate from Jalali date to Gregorian in your entities' DAO implementation (e.g. CustomerDaoHibernate.java). You may need to implement the methods save to translate from Jalali to Gregorian, and the others (get, getAll, etc) to translate from Gregorian to Jalali. Your entity would have Jalali dates but your database would store Gregorian.

Another option you may want to consider is to implement the translation in your web Actions (the logic that process the web requests). Your entity and database would both have Gregorian dates, and only web forms would use Jalali dates.

Hope that helps,
Pedro Burglin

alibehzadian wrote:
Hi there,

I am developing a Persian-language site with AppFuse Struts 2 Archetype.
In web tier, users enter Jalali date but I want to convert these jalali dates
to Gregorian date (java.util.Date) before saving them in database.

I have the algorithm and libraries to for conversion. Which classes should I
modify in AppFuse?

Thanks,
Ali Behzadian Nejad.

Re: Convert Date attributes to JalaliDate

by mraible :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

DateUtil is generally used for Date manipulation. This is available to
you if you've full-sourced your project.

Matt

On Mon, Jul 7, 2008 at 8:45 AM, pedro_burglin <pedro_burglin@...> wrote:

>
> Hi Ali,
>
> If you just want to convert the dates in the Data Access Object layer I
> think you just need to translate from Jalali date to Gregorian in your
> entities' DAO implementation (e.g. CustomerDaoHibernate.java). You may need
> to implement the methods save to translate from Jalali to Gregorian, and the
> others (get, getAll, etc) to translate from Gregorian to Jalali. Your entity
> would have Jalali dates but your database would store Gregorian.
>
> Another option you may want to consider is to implement the translation in
> your web Actions (the logic that process the web requests). Your entity and
> database would both have Gregorian dates, and only web forms would use
> Jalali dates.
>
> Hope that helps,
> Pedro Burglin
>
>
> alibehzadian wrote:
>>
>> Hi there,
>>
>> I am developing a Persian-language site with AppFuse Struts 2 Archetype.
>> In web tier, users enter Jalali date but I want to convert these jalali
>> dates
>> to Gregorian date (java.util.Date) before saving them in database.
>>
>> I have the algorithm and libraries to for conversion. Which classes should
>> I
>> modify in AppFuse?
>>
>> Thanks,
>> Ali Behzadian Nejad.
>>
>
> --
> View this message in context: http://www.nabble.com/Convert-Date-attributes-to-JalaliDate-tp18311589s2369p18318468.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Convert Date attributes to JalaliDate

by Mike Horwitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Another option, if you are using Hibernate, is to plug in a custom type in Hibernate that knows what to do. You can take a look at the Hibernate subproject for the Joda-time project for guidance:

http://joda-time.sourceforge.net/contrib/hibernate/index.html

Mike

2008/7/7 Matt Raible <matt@...>:
DateUtil is generally used for Date manipulation. This is available to
you if you've full-sourced your project.

Matt

On Mon, Jul 7, 2008 at 8:45 AM, pedro_burglin <pedro_burglin@...> wrote:
>
> Hi Ali,
>
> If you just want to convert the dates in the Data Access Object layer I
> think you just need to translate from Jalali date to Gregorian in your
> entities' DAO implementation (e.g. CustomerDaoHibernate.java). You may need
> to implement the methods save to translate from Jalali to Gregorian, and the
> others (get, getAll, etc) to translate from Gregorian to Jalali. Your entity
> would have Jalali dates but your database would store Gregorian.
>
> Another option you may want to consider is to implement the translation in
> your web Actions (the logic that process the web requests). Your entity and
> database would both have Gregorian dates, and only web forms would use
> Jalali dates.
>
> Hope that helps,
> Pedro Burglin
>
>
> alibehzadian wrote:
>>
>> Hi there,
>>
>> I am developing a Persian-language site with AppFuse Struts 2 Archetype.
>> In web tier, users enter Jalali date but I want to convert these jalali
>> dates
>> to Gregorian date (java.util.Date) before saving them in database.
>>
>> I have the algorithm and libraries to for conversion. Which classes should
>> I
>> modify in AppFuse?
>>
>> Thanks,
>> Ali Behzadian Nejad.
>>
>
> --
> View this message in context: http://www.nabble.com/Convert-Date-attributes-to-JalaliDate-tp18311589s2369p18318468.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


LightInTheBox - Buy quality products at wholesale price!