code: public static long periodEnd(long now, long period)
    {
      LocalDateTime time = LocalDateTime.ofEpochSecond(now / 1000, 0, ZoneOffset.UTC);
      //QDate localCalendar = QDate.allocateLocalDate();
      
      long endTime = periodEnd(now, period, time);
      
      //QDate.freeLocalDate(localCalendar);
      
      return endTime;
    }
docs: Calculates the next period end.  The calculation is in local time.
  
  @param now the current time in GMT ms since the epoch
  
  @return the time of the next period in GMT ms since the epoch