eva/3 Application BuilderApplication WizardsOverview of the ExamplesContact ManagementAspects of Design 

Setting Dates in a Form

When calling the report Weekly overview of calls the form with the period of time will be shown. Here the actual date and the date one week before will be shown by default.

This will be implemented by the SystemCommandy based class WeekDateSetter:

public class WeekDateSetter implements SystemCommand {
...

    public Object action(Object[] args, Macro macro) {
        long currentTime = System.currentTimeMillis();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(currentTime);
        SWindow window = EvaUtils.getActiveSWindow();
        SFormattedField fromDate = (SFormattedField) window
                .getObject("FromDate");
        SFormattedField toDate = (SFormattedField) window.getObject("ToDate");
        String toDateString = calendar.get(Calendar.DAY_OF_MONTH) + "."
                + (calendar.get(Calendar.MONTH) + 1) + "."
                + calendar.get(Calendar.YEAR);
        calendar.set(Calendar.WEEK_OF_YEAR,
                calendar.get(Calendar.WEEK_OF_YEAR) - 1);
        String fromDateString = calendar.get(Calendar.DAY_OF_MONTH) + "."
                + (calendar.get(Calendar.MONTH) + 1) + "."
                + calendar.get(Calendar.YEAR);
        fromDate.setText(fromDateString);
        toDate.setText(toDateString);
        return null;
    }
}

The particular date will be set to the fields FromDate and ToDate gesetzt. The Macro will be called by specifying the AfterInitializeMacro property in the form WeekSelection.form.