Code example for GregorianCalendar

Methods: set, setTime

0
 
  public static Date now(final FormulaContext context)
  { 
    final LocalizationContext localizationContext = context.getLocalizationContext();
    final GregorianCalendar gc =
        new GregorianCalendar(localizationContext.getTimeZone(), localizationContext.getLocale());
    gc.setTime(context.getCurrentDate());
    gc.set(Calendar.MILLISECOND, 0);
    return gc.getTime();
  } 
 
  public static Date createDateTime(final int year, final int month, final int day, final int hour,
                                    final int minute, final int second, final LocalizationContext context)
  { 
    final GregorianCalendar gc = new GregorianCalendar(context.getTimeZone(),
        context.getLocale());
    gc.set(Calendar.DAY_OF_MONTH, day);
    gc.set(Calendar.MONTH, month);
    gc.set(Calendar.YEAR, year);
    gc.set(Calendar.MILLISECOND, 0);
    gc.set(Calendar.HOUR_OF_DAY, hour);