Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing Only Date Instead of time #249

Open
AhmedAli1050 opened this issue Jan 14, 2024 · 1 comment
Open

Showing Only Date Instead of time #249

AhmedAli1050 opened this issue Jan 14, 2024 · 1 comment

Comments

@AhmedAli1050
Copy link

Still getting the same issue, showing date with time like 01/14/2024 09:00:00/ 01/01/2018 09:00:00
and how can we show only date instead of time

cal.set(2017, 12, 1, 0, 0, 0);
walker.setDateValue(cal);
// Add a custom format
final DataStyle dateStyle = new DateStyleBuilder("custom-date-datastyle", Locale.US)
.dateFormat(
new DateTimeStyleFormat(DateTimeStyleFormat.DAY, DateTimeStyleFormat.DOT,
DateTimeStyleFormat.MONTH, DateTimeStyleFormat.DOT,
DateTimeStyleFormat.YEAR)).visible().build();
walker.setDataStyle(dateStyle);
walker.next();

@jferard
Copy link
Owner

jferard commented Mar 5, 2024

Hello,
Sorry for the (very) late answer. The display is correct (only year - month - day), but the value has hours. You get the hours because of the timezone of the calendar instance and because of the milliseconds. I added some hint in the doc and examples (see : e570f44). Here is the relevant part:

        // A date with the standard format.
        // Warning : you probably want to set milliseconds to 0 and use correct time zone
        final Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(2018, Calendar.FEBRUARY, 1, 0, 0, 0);

This removes the hours for the date value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants