0

I'm using the pe:timeline component in an app that I'm working on. One thing that I need is to preset the date interval (it should always be 6AM-10PM)... OK EXAMPLE

Locally, it appears ok, but when I deploy the app on another server that has NorthAmerica/NewYork timezone it displays a weird interval 8PM-11AM. WRONG INTERVAL

I tried to set the timezone of the component to "EET" but it doesn't seem to fix the problem.

I generate a list of Dates that contain the lower/upper bound of the intervals with this function:

  private List<Date> generateMinMaxDates() {
    List<Date> aux = new ArrayList<Date>();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.HOUR_OF_DAY, 6);
    logger.info("Lower Bound:\t" + calendar.getTime());
    aux.add(calendar.getTime());
    //change the date to today/23:59
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.HOUR_OF_DAY, 22);
    logger.info("Upper Bound:\t" + calendar.getTime());
    aux.add(calendar.getTime());
    return aux;
  }

then in a @PostContrust function I initialize a variable

@PostConstruct
public void init() {
  ... etc     
  timezone = TimeZone.getTimeZone("EET");
 ... etc
 }

and the component in the .xhtml looks like this:

            <pe:timeline id="timeline" value="#{gatePlanController.gatePlanner}"
                var="order" showCurrentTime="true" varGroup="group" editable="true"
                groupsOnRight="false" stackEvents="false" showMajorLabels="false"
                axisOnTop="true" widgetVar="timelineWdgt"
                min="#{gatePlanController.dateIntervals[0]}"
                max="#{gatePlanController.dateIntervals[1]}"
                start="#{gatePlanController.dateIntervals[0]}"
                end="#{gatePlanController.dateIntervals[1]}" moveable="true"
                selectable="true" zoomMin="900000"
                dropActiveStyleClass="ui-state-highlight"
                dropHoverStyleClass="ui-state-hover" minHeight="110"
                timeChangeable="#{gatePlanController.eventsAreChangeable}"
                timeZone="#{gatePlanController.timezone}">

Any idea how I could solve this?

Theo
  • 171
  • 2
  • 5
  • 16

1 Answers1

1

Try setting timezone in Calendar.getInstance().

Ex. Calendar.getInstance(TimeZone.getTimeZone("EET"));

And I think Calendar by default takes current date so no need to set time again with current date.

Nilesh Mali
  • 530
  • 6
  • 12