convert the x-axis time in vaadin flow timeline chart to local time zone in java

I am using Chart Object in com.vaadin.flow.component.charts package to create timeline chart . In that I am using DataSeries to create the serise , here DataSeries.setX(Instant) → accepts instant object So the date gets converted to UTC always and because of this the time in graph always displays in UTC , my question is how can I set the local timezone to chart , I am able to get the local time zone from browser but not finding any option to set this timezone to chart/dataserise object

@quintessential-ibex can you please help here

But of course I can :slightly_smiling_face:

Chart chart = new Chart(ChartType.LINE);
DataSeries series = new DataSeries();
Instant now =;
series.add(new DataSeriesItem(now, 1));
series.add(new DataSeriesItem(now.plusSeconds(60), 2));
series.add(new DataSeriesItem(now.plusSeconds(180), 3));
Time time = new Time();
// get the client's timezoneoffset and convert it for the
// format for charts
UI.getCurrent().getPage().retrieveExtendedClientDetails(d -> {
    int timezoneOffsetFromBrowser = d.getTimezoneOffset();
    int timezoneOffsetInMinutesInWeirdJSWay =

The timezone offset calculation is the weird part here. Chart’s accepts a JS style version, minutes compared to UTC, west positive.

If server timezone or some hard coded is good for your, then it is bit different, but you can probably figure that out.

@quintessential-ibex Thanks for helping ,There is a flag in Time class time.setUseUTC(false) . This is much simpler

That is, if you are ok to pick the time zone from the browser :+1: