Skip to content

Calendar Component doesn't respect passed in Date object in setDate(), setCurrentDate(), setSelectedDate() methods #1515

@igo211

Description

@igo211

As title says, UI Calendar component doesn't respect the Date object passed in for setDate(), setCurrentDate(), setSelectedDate().

Oddly, it overrides the passed in Date's hour, minute, second and millisecond in the MonthView member class's setCurrentDay() and setSelectedDay() methods.
It sets the hour/hour of day to 1 (huh? I could see 0 hour/midnight, but why 1am?), and sets minute, second and millis to 0.

This current behaviour is annoying & unexpected based on lack of documentation about the arbitrary resetting of the Date value and problematic in cases where a specific hour/minute/second/millis value is expected/needed.

Since what is being passed in by the user/developer is a java Date object, the hours, minutes, and seconds should be respected by the component.

If setting/getting hour/minute/second/millis "normalized" values is desirable, perhaps that should be a settable option via a new method in the Calendar class (i.e. normalizeTo(int hour, int minute, int second, int millis), but at the very least what the user/developer sets the Date object value to should be respected and set "as-is" by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions