Build a <code>{@link Calendar}</code> with the current time. The new
Calendar will use the <code>BaseCalendar</code> time zone if it is not
<code>null</code>.
553523
protected Calendar createJavaCalendar ()
  {
    return Calendar.getInstance (getTimeZone () != null ? getTimeZone () : TimeZone.getDefault (),
                                 Locale.getDefault (Locale.Category.FORMAT));
  }
176647
@Nonnull
  public T build ()
  {
    if (m_aScheduleBuilder == null)
      m_aScheduleBuilder = SimpleScheduleBuilder.simpleSchedule ();
    final IMutableTrigger trig = m_aScheduleBuilder.build ();
    trig.setCalendarName (m_sCalendarName);
    trig.setDescription (m_sDescription);
    trig.setStartTime (m_aStartTime);
    trig.setEndTime (m_aEndTime);
    if (m_aKey == null)
      m_aKey = new TriggerKey (Key.createUniqueName (null), null);
    trig.setKey (m_aKey);
    if (m_aJobKey != null)
      trig.setJobKey (m_aJobKey);
    trig.setPriority (m_nPriority);

    if (!m_aJobDataMap.isEmpty ())
      trig.setJobDataMap (m_aJobDataMap);
    return GenericReflection.uncheckedCast (trig);
  }
1000733
public static Calendar createCalendar(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal;
    }
15785
protected Calendar guessCalendar() {
        ULocale calLocale = getAvailableLocale(TYPE_CALENDAR);
        if (calLocale == null) {
            calLocale = ULocale.US;
        }
        return Calendar.getInstance(getTimeZone(), calLocale);
    }
469843
public Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime createProjectCalendarsCalendarExceptionsExceptionWorkingTimesWorkingTime()
   {
      return new Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime();
   }
117
public void layoutCalendar(Date timeTarget)
    {
        calendar.setTime(timeTarget);
        
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
                
        String[] array = new String[24 * 2];
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        int selectedIndex = -1;
        for (int i = 0; i < array.length; i++)
        {
            if (hour == calendar.get(Calendar.HOUR_OF_DAY))
                if (minute == calendar.get(Calendar.MINUTE))
                    selectedIndex = i;
            Date time = calendar.getTime();
            String strTime = timeFormat.format(time);
            array[i] = strTime;
            calendar.add(Calendar.MINUTE, 30);
        }
        DefaultComboBoxModel model = new DefaultComboBoxModel(array);
        this.setVisibleRowCount(10);
        this.setModel(model);
        if (selectedIndex != -1)
            this.setSelectedIndex(selectedIndex);
    }
986764
public void setTimeZone(TimeZone zone)
    {
        // zone is cloned once for all three usages below:
        TimeZone zoneToSet = (TimeZone)zone.clone();
        if (fDateFormat != null) {
            fDateFormat.setTimeZone(zoneToSet);
        }
        // fDateFormat has the master calendar for the DateIntervalFormat;
        // fFromCalendar and fToCalendar are internal work clones of that calendar.
        if (fFromCalendar != null) {
            fFromCalendar.setTimeZone(zoneToSet);
        }
        if (fToCalendar != null) {
            fToCalendar.setTimeZone(zoneToSet);
        }
    }
892310
public final void setDate(final Date date) {
        this.date = date;
        if (date instanceof DateTime) {
            if (Value.DATE.equals(getParameter(Parameter.VALUE))) {
                getParameters().replace(Value.DATE_TIME);
            }
            updateTimeZone(((DateTime) date).getTimeZone());
        } else {
            if (date != null) {
                getParameters().replace(Value.DATE);
            }
            /*
            else {
                getParameters().removeAll(Parameter.VALUE);
            }
            */
            // ensure timezone is null for VALUE=DATE or null properties..
            updateTimeZone(null);
        }
    }
914437
public ScheduledFuture<?> schedule() {
        synchronized (this.triggerContextMonitor) {
            this.scheduledExecutionTime = this.trigger.nextExecutionTime(this.triggerContext);
            if (this.scheduledExecutionTime == null) {
                return null;
            }
            long initialDelay = this.scheduledExecutionTime.getTime() - System.currentTimeMillis();
            this.currentFuture = this.executor.schedule(this, initialDelay, TimeUnit.MILLISECONDS);
            return this;
        }
    }
276499
public void layoutCalendar(Date dateTarget)
    {
        calendar.setTime(dateTarget);
        calendar.set(Calendar.HOUR_OF_DAY, 12);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        targetPanelDate = calendar.getTime();
        calendar.set(Calendar.DATE, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date dateFirstOfMonth = calendar.getTime();
        calendar.setTime(dateFirstOfMonth);
        calendar.add(Calendar.MONTH, 1);
        calendar.add(Calendar.DATE, -1);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        Date dateLastOfMonth = calendar.getTime();
        Date dateCalendarFirstDate = this.getFirstDateInCalendar(dateFirstOfMonth);
        Date dateCalendar = new Date(dateCalendarFirstDate.getTime());

        targetComponent = (int)((targetDate.getTime() - dateCalendarFirstDate.getTime()) / KMS_IN_A_DAY);
        if (targetComponent < 0)
            targetComponent--;

        String strYear = this.getDateString(dateTarget, DateFormat.YEAR_FIELD);
        String strMonth = this.getDateString(dateTarget, DateFormat.MONTH_FIELD);
        monthLabel.setText(strMonth);
        yearLabel.setText(strYear);
        int iDayOfWeekComponent = 0;
        int iDayComponent = 7;
        for (; iDayComponent < panelDays.getComponentCount(); iDayOfWeekComponent++, iDayComponent++)
        {
            if (iDayOfWeekComponent < 7)
            {
                JLabel labelDayOfWeek = (JLabel)panelDays.getComponent(iDayOfWeekComponent);
                String strWeek = this.getDateString(dateCalendar, DateFormat.DAY_OF_WEEK_FIELD);
                if ((strWeek != null) && (strWeek.length() > 0))
                    labelDayOfWeek.setText(strWeek.substring(0, 1));
                else
                    labelDayOfWeek.setText(Integer.toString(iDayOfWeekComponent));
            }
            JLabel labelDay = (JLabel)panelDays.getComponent(iDayComponent);
            String strDay = this.getDateString(dateCalendar, DateFormat.DATE_FIELD);
            labelDay.setText(strDay);
            if ((dateCalendar.before(dateFirstOfMonth))
                || (dateCalendar.after(dateLastOfMonth)))
                    labelDay.setForeground(Color.GRAY);
            else
                    labelDay.setForeground(Color.BLACK);
            labelDay.setBackground(panelDays.getBackground());
            if (targetComponent == iDayComponent - 7)
                labelDay.setBorder(SELECTED_BORDER);
            else
                labelDay.setBorder(EMPTY_BORDER);

            calendar.setTime(dateCalendar);
            calendar.add(Calendar.DATE, 1);
            dateCalendar = calendar.getTime();

            if (firstTime)
            {
                labelDay.addMouseListener(this);
                labelDay.setName(Integer.toString(iDayComponent - 7));
            }
        }
        firstTime = false;
    }
1033589
public static GsonBuilder registerDateTimeZone(GsonBuilder builder)
  {
    if (builder == null) { throw new NullPointerException("builder cannot be null"); }

    builder.registerTypeAdapter(DATE_TIME_ZONE_TYPE, new DateTimeZoneConverter());

    return builder;
  }
358335
@Override
  public long getNextIncludedTime (final long nTimeStamp)
  {

    // Call base calendar implementation first
    long timeStamp = nTimeStamp;
    final long baseTime = super.getNextIncludedTime (timeStamp);
    if ((baseTime > 0) && (baseTime > timeStamp))
    {
      timeStamp = baseTime;
    }

    // Get timestamp for 00:00:00
    final Calendar day = getStartOfDayJavaCalendar (timeStamp);
    while (isTimeIncluded (day.getTime ().getTime ()) == false)
    {
      day.add (Calendar.DATE, 1);
    }

    return day.getTime ().getTime ();
  }
430025
private void readCalendar(Project.Calendars.Calendar calendar, HashMap<BigInteger, ProjectCalendar> map, List<Pair<ProjectCalendar, BigInteger>> baseCalendars)
   {
      ProjectCalendar bc = m_projectFile.addCalendar();
      bc.setUniqueID(NumberHelper.getInteger(calendar.getUID()));
      bc.setName(calendar.getName());
      BigInteger baseCalendarID = calendar.getBaseCalendarUID();
      if (baseCalendarID != null)
      {
         baseCalendars.add(new Pair<ProjectCalendar, BigInteger>(bc, baseCalendarID));
      }

      readExceptions(calendar, bc);
      boolean readExceptionsFromDays = bc.getCalendarExceptions().isEmpty();

      Project.Calendars.Calendar.WeekDays days = calendar.getWeekDays();
      if (days != null)
      {
         for (Project.Calendars.Calendar.WeekDays.WeekDay weekDay : days.getWeekDay())
         {
            readDay(bc, weekDay, readExceptionsFromDays);
         }
      }
      else
      {
         bc.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
         bc.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);
      }

      readWorkWeeks(calendar, bc);

      map.put(calendar.getUID(), bc);

      m_eventManager.fireCalendarReadEvent(bc);
   }
1174323
private void resetCalendar() {
    _calendar = getCalendar();
    if (_defaultTimeZone != null) {
      _calendar.setTimeZone(_defaultTimeZone);
    }
    _currentYear = _calendar.get(Calendar.YEAR);
  }
548528
public DateUnit add() {
		if (this.add.isPresent()) { return add.get(); }
		
		return (this.add = Optional.of((DateUnit) new DateUnit(this) {
			
			@Override protected DateUnit handle(int calendarField, int amount) {
				Calendar c = asCalendar();
				c.add(calendarField, amount);
				target = c.getTime();
		        return this;
			}

		})).get();
	}
1035337
public GlobalizationPreferences setCalendar(Calendar calendar) {
        if (isFrozen()) {
            throw new UnsupportedOperationException("Attempt to modify immutable object");
        }
        this.calendar = (Calendar) calendar.clone(); // clone for safety
        return this;
    }
980632
public SimpleDateFormat build() {
        
        final SimpleDateFormat formatter;
        if(locale == null) {
            formatter = new SimpleDateFormat(pattern);
        } else {
            formatter = new SimpleDateFormat(pattern, locale);
        }
        
        if(timeZone != null) {
            formatter.setTimeZone(timeZone);
        }
        formatter.setLenient(lenient);
        
        return formatter;
        
    }