pe:timeline 上的日期间隔会随着不同的服务器而变化,即使我对它们进行了硬编码

Date Interval on pe:timeline changes with different servers even if I hardcoded them

我正在我正在开发的应用程序中使用 pe:timeline 组件。我需要做的一件事是预设日期间隔(应该始终是早上 6 点到晚上 10 点)... OK EXAMPLE

在本地,它看起来没问题,但是当我在另一台具有 NorthAmerica/NewYork 时区的服务器上部署该应用程序时,它显示一个奇怪的时间间隔 8PM-11AM。 WRONG INTERVAL

我尝试将组件的时区设置为 "EET",但似乎无法解决问题。

我生成了一个日期列表,其中包含使用此函数的 lower/upper 区间界限:

  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;
  }

然后在@PostContrust 函数中我初始化一个变量

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

.xhtml 中的组件如下所示:

            <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}">

知道如何解决这个问题吗?

尝试在 Calendar.getInstance() 中设置时区。

例如。 Calendar.getInstance(TimeZone.getTimeZone("EET"));

而且我认为 Calendar 默认情况下采用当前日期,因此无需使用当前日期再次设置时间。