Question

I'm experiencing an issue with using tapx-datefield, more accurately, improved DateField component.

My TML:

<t:form>
    <t:label for="dateAndTime"/>
    <tx:DateField t:id="dateAndTime" t:format="prop:dateTimeFormat"/>
    <br/>

    <input type="submit" value="Submit"/>
    <t:errors/>
</t:form>

<hr/>

<t:if t:test="dateAndTime">
    <p>Date and Time: ${dateAndTime}</p>

    <p:else>
        Nothing :(
    </p:else>
</t:if>

My POJO class:

public class TestDateTimePage {

    @Property
    @Persist(PersistenceConstants.FLASH)
    private Date dateAndTime;

    public DateFormat getDateTimeFormat() {
        return new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
    }
}

When I pick the date from the calendar, the "ss z" part of the format is ignored: Error screenshot

And I know for a fact that that format is just fine:

DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
System.out.println(df.format(new Date()));

Tue, 25 Mar 2014 12:38:19 GMT

Is this intended behaviour (ignoring seconds, timezone and such) or a bug? If so, is there a known workaround?

Was it helpful?

Solution

So, I've been doing some inspecting of tapx source on GitHub and from what I've seen, it does not have inherent support of parsing seconds:

from tapx-datefield Date#parseDate function:

...
return new Date(y, m, d, hr, min, 0);

while the Date object has the following ctor:

var d = new Date(year, month, day, hours, minutes, seconds, milliseconds); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top