Format time fields

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

Format time fields

by Paslaru Narcis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I have a property of type Date that represents the difference of 2 dates (the duration).
What format pattern should I use in order to get the days, hours, minutes and seconds ?

Thanks,
Narcis

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
displaytag-user mailing list
displaytag-user@...
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Re: Format time fields

by Michael-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paslaru Narcis schrieb:
> Hi all,
>
> I have a property of type Date that represents the difference of 2 dates
> (the duration).
> What format pattern should I use in order to get the days, hours, minutes
> and seconds ?

A date object is not really suitable for holding a duration. You should
compute the difference of both in a long field and pass over to:
http://commons.apache.org/lang/api-release/org/apache/commons/lang/time/DurationFormatUtils.html

It's best to stick with ISO period format.

Mike

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
displaytag-user mailing list
displaytag-user@...
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Re: Format time fields

by Paslaru Narcis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a lot. I'll do that.

Cheers,
Narcis

On Mon, Oct 26, 2009 at 8:12 PM, Michael <sgfan@...> wrote:
Paslaru Narcis schrieb:
> Hi all,
>
> I have a property of type Date that represents the difference of 2 dates
> (the duration).
> What format pattern should I use in order to get the days, hours, minutes
> and seconds ?

A date object is not really suitable for holding a duration. You should
compute the difference of both in a long field and pass over to:
http://commons.apache.org/lang/api-release/org/apache/commons/lang/time/DurationFormatUtils.html

It's best to stick with ISO period format.

Mike

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
displaytag-user mailing list
displaytag-user@...
https://lists.sourceforge.net/lists/listinfo/displaytag-user


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
displaytag-user mailing list
displaytag-user@...
https://lists.sourceforge.net/lists/listinfo/displaytag-user