On Fri, Oct 17, 2008 at 18:20, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:

> Date conversions in Java are hugely ugly.


But this doesn't make java.util.Date to be unused, isn't it? We're still use
Date type whether its ugly or not.


> Are you sure there isn't a
> time zone issue involved with this coercion?


According to Javadoc (see below) it always returns the same value for all
timezones, since its GMT.

    /**
     * Returns the number of milliseconds since January 1, 1970, 00:00:00
GMT
     * represented by this <tt>Date</tt> object.
     *
     * @return  the number of milliseconds since January 1, 1970, 00:00:00
GMT
     *          represented by this date.
     */
    public long getTime() {
        return getTimeImpl();
    }

Are you sure you want to
> see a large number in your URL rather than something that looks like a
> Date?


Making java.util.Date looks like a date (i.e. 01/02/2008) will confuse -- is
this January, 2nd or February 1st? Introducing special chars to URL (/, :, '
', +, etc.) will cause it to be escaped.

So I don't see any other options rather than numbers, do you? I'd like to
see your choise -- how're you doing this? I mean, you're using Dates, don't
you?

The number, whether it ugly or not, it uniform. And what it the URL? Its
Uniform Resource Locator, and its GET parameters are just a transport, so
let them be uniform too. Thats my point of view.

Am I missed somethig?


>
>
> On Fri, Oct 17, 2008 at 1:44 AM, Dmitry Gusev <[EMAIL PROTECTED]>
> wrote:
> > It would be great to implement Date type coertion out-of-the-box through
> it
> > milliseconds representation.
> >
> > Currently I have to contribute the coertion to my app module:
> >
> >    public static void
> > contributeTypeCoercer(Configuration<CoercionTuple<Long, Date>>
> > configuration) {
> >        Coercion<Long, Date> coercion = new Coercion<Long, Date>() {
> >            public Date coerce(Long input) {
> >                Calendar calendar = Calendar.getInstance();
> >                calendar.setTimeInMillis(input);
> >                return calendar.getTime();
> >            }
> >        };
> >
> >        configuration.add(new CoercionTuple<Long, Date>(Long.class,
> > Date.class,
> >                coercion));
> >    }
> >
> >
> > Passing parameters to pagelink component example:
> >
> > <t:pagelink t:id="edit" page="curriculum/holidays/edit"
> > context="holiday.date.time">Edit</t:pagelink>
> >
> > ---
> >
> > public class Holiday {
> > ...
> >    public Date getDate() {
> >        return date;
> >    }
> >    public void setDate(Date date) {
> >        this.date = date;
> >    }
> > ...
> > }
> >
> > ---
> >
> > And on the Edit page activation/deactivation methods looks like:
> >
> >    public void onActivate(Date date) {
> >        this.date = date;
> >        // ...
> >    }
> >
> >    public Date onPassivate() {
> >        return date;
> >    }
> >
> > ---
> >
> > Having Date type coercion support out-of-the-box will let me pass Date
> > parameters directly (without invoking Date.getTime() on the actual
> parameter
> > instance).
> >
> >
> >
> > <[email protected]>--
> > С уважением,
> > Дмитрий Гусев
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>



-- 
С уважением,
Дмитрий Гусев

Reply via email to