Example usage for java.util Calendar DATE

List of usage examples for java.util Calendar DATE

Introduction

In this page you can find the example usage for java.util Calendar DATE.

Prototype

int DATE

To view the source code for java.util Calendar DATE.

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:org.sharetask.service.StatisticsServiceImpl.java

private StatisticsDataDTO getStatisticsPerLastDay() {
    Calendar calendar = Calendar.getInstance();
    Date date = DateUtils.truncate(calendar.getTime(), Calendar.DATE);
    return new StatisticsDataDTO.Builder().usersCount(userInformationRepository.getCountCreatedAfter(date))
            .workspacesCount(workspaceRepository.getCountCreatedAfter(date))
            .tasksCount(taskRepository.getCountCreatedAfter(date)).build();
}

From source file:it.unibz.instasearch.indexing.querying.ModifiedTimeConverter.java

@Override
public Query visit(TermQuery termQuery, Field termField) {

    if (termField != Field.MODIFIED)
        return super.visit(termQuery, termField);

    Term t = termQuery.getTerm();/*from w ww  .j  a  va2 s .c om*/
    String intervalName = t.text();
    int multiplier = 1;

    if (intervalName.matches("^[0-9]+.*$")) // e.g. "3 days"
    {
        String multiplierString = intervalName.replaceAll("[^0-9]+", ""); // remove non-digits
        multiplier = NumberUtils.toInt(multiplierString.trim(), 1);

        intervalName = intervalName.replaceAll("[0-9 ]+", "").trim(); // remove digits
    }

    if (intervalName.endsWith("s"))
        intervalName = intervalName.substring(0, intervalName.length() - 1);

    Interval interval = getIntervalByName(intervalName);

    if (interval == null)
        return super.visit(termQuery, termField);

    long start = 0, end = System.currentTimeMillis();
    cal.setTimeInMillis(end);

    switch (interval) {
    case TODAY:
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
        start = cal.getTimeInMillis();
        break;
    case YESTERDAY:
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
        end = cal.getTimeInMillis();
        cal.add(Calendar.DATE, -1);
        start = cal.getTimeInMillis();
        break;
    default:
        start = end - multiplier * interval.millis;
    }

    String field = Field.MODIFIED.name().toLowerCase();
    NumericRangeQuery rangeQuery = NumericRangeQuery.newLongRange(field, start, end, true, true);

    return rangeQuery;
}

From source file:net.sourceforge.eclipsetrader.yahoo.HistoryFeed.java

public void updateHistory(Security security, int interval) {
    if (interval == IHistoryFeed.INTERVAL_DAILY) {
        Calendar from = Calendar.getInstance();
        Calendar to = Calendar.getInstance();

        History history = security.getHistory();
        if (history.size() == 0)
            from.add(Calendar.YEAR, -CorePlugin.getDefault().getPreferenceStore()
                    .getInt(CorePlugin.PREFS_HISTORICAL_PRICE_RANGE));
        else {/*from   w w w.j  ava 2  s .  com*/
            Bar cd = history.getLast();
            if (cd != null) {
                from.setTime(cd.getDate());
                from.add(Calendar.DATE, 1);
            }
        }

        try {
            HttpClient client = new HttpClient();
            client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
            String host = "ichart.finance.yahoo.com"; //$NON-NLS-1$
            BundleContext context = YahooPlugin.getDefault().getBundle().getBundleContext();
            ServiceReference reference = context.getServiceReference(IProxyService.class.getName());
            if (reference != null) {
                IProxyService proxy = (IProxyService) context.getService(reference);
                IProxyData data = proxy.getProxyDataForHost(host, IProxyData.HTTP_PROXY_TYPE);
                if (data != null) {
                    if (data.getHost() != null)
                        client.getHostConfiguration().setProxy(data.getHost(), data.getPort());
                    if (data.isRequiresAuthentication())
                        client.getState().setProxyCredentials(AuthScope.ANY,
                                new UsernamePasswordCredentials(data.getUserId(), data.getPassword()));
                }
            }

            String symbol = null;
            if (security.getHistoryFeed() != null)
                symbol = security.getHistoryFeed().getSymbol();
            if (symbol == null || symbol.length() == 0)
                symbol = security.getCode();

            // If the last bar from the data is from a date before today, then
            // download the historical data, otherwise it's enough to download the data for today.
            to.add(Calendar.DAY_OF_MONTH, -1);
            to.set(Calendar.HOUR, 0);
            to.set(Calendar.MINUTE, 0);
            to.set(Calendar.SECOND, 0);
            to.set(Calendar.MILLISECOND, 0);
            Bar lastHistoryBar = history.getLast();
            Date lastDate;
            if (lastHistoryBar == null)
                lastDate = from.getTime();
            else
                lastDate = lastHistoryBar.getDate();
            if (lastDate.before(to.getTime())) {
                log.info("Updating historical data for " + security.getCode() + " - " //$NON-NLS-1$//$NON-NLS-2$
                        + security.getDescription());

                StringBuffer url = new StringBuffer("http://" + host + "/table.csv" + "?s="); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                url.append(symbol);
                url.append("&d=" + to.get(Calendar.MONTH) + "&e=" + to.get(Calendar.DAY_OF_MONTH) + "&f=" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        + to.get(Calendar.YEAR));
                url.append("&g=d"); //$NON-NLS-1$
                url.append("&a=" + from.get(Calendar.MONTH) + "&b=" + from.get(Calendar.DAY_OF_MONTH) + "&c=" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        + from.get(Calendar.YEAR));
                url.append("&ignore=.csv"); //$NON-NLS-1$
                log.debug(url);

                HttpMethod method = new GetMethod(url.toString());
                method.setFollowRedirects(true);
                client.executeMethod(method);

                BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));

                // The first line is the header, ignoring
                String inputLine = in.readLine();
                log.trace(inputLine);

                while ((inputLine = in.readLine()) != null) {
                    log.trace(inputLine);
                    if (inputLine.startsWith("<")) //$NON-NLS-1$
                        continue;
                    String[] item = inputLine.split(","); //$NON-NLS-1$
                    if (item.length < 6)
                        continue;

                    Calendar day = Calendar.getInstance();
                    try {
                        day.setTime(df.parse(item[0]));
                    } catch (Exception e) {
                        try {
                            day.setTime(dfAlt.parse(item[0]));
                        } catch (Exception e1) {
                            log.error(e1, e1);
                        }
                    }
                    day.set(Calendar.HOUR, 0);
                    day.set(Calendar.MINUTE, 0);
                    day.set(Calendar.SECOND, 0);
                    day.set(Calendar.MILLISECOND, 0);

                    Bar bar = new Bar();
                    bar.setDate(day.getTime());
                    bar.setOpen(Double.parseDouble(item[1].replace(',', '.')));
                    bar.setHigh(Double.parseDouble(item[2].replace(',', '.')));
                    bar.setLow(Double.parseDouble(item[3].replace(',', '.')));
                    bar.setClose(Double.parseDouble(item[4].replace(',', '.')));
                    bar.setVolume(Long.parseLong(item[5]));

                    // Remove the old bar, if exists
                    int index = history.indexOf(bar.getDate());
                    if (index != -1)
                        history.remove(index);

                    history.add(bar);
                }
                in.close();
            }

            // Get the data for today (to-date) using a different URL at Yahoo!
            //Bar lastbar = history.getLast
            log.debug("Get data for today using a separate URL..."); //$NON-NLS-1$
            StringBuffer url = new StringBuffer(
                    "http://finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=sl1d1t1c1ohgv&e=.csv"); //$NON-NLS-1$ //$NON-NLS-2$
            log.debug(url);

            HttpMethod method = new GetMethod(url.toString());
            method.setFollowRedirects(true);
            client.executeMethod(method);

            BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
            String inputLine = in.readLine();
            log.trace(inputLine);
            String[] item = inputLine.split(","); //$NON-NLS-1$
            item[2] = item[2].replace("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$

            SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy", Locale.US); //$NON-NLS-1$
            Calendar day = Calendar.getInstance();

            // Transfer the data from the string array to the Bar
            day.setTime(df.parse(item[2]));
            Bar bar = new Bar();
            bar.setDate(day.getTime());
            bar.setOpen(Double.parseDouble(item[5]));
            bar.setClose(Double.parseDouble(item[1]));
            bar.setHigh(Double.parseDouble(item[6]));
            bar.setLow(Double.parseDouble(item[7]));
            bar.setVolume(Long.parseLong(item[8]));

            // Remove the old bar, if exists
            int index = history.indexOf(bar.getDate());
            if (index != -1)
                history.remove(index);
            history.add(bar);

            in.close();

        } catch (Exception e) {
            log.error(e, e);
        }

        CorePlugin.getRepository().save(history);
    } else
        log.warn("Intraday data not supported for " + security.getCode() + " - " + security.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:ch.algotrader.adapter.dc.DCFixMarketDataMessageHandler.java

public void onMessage(MarketDataSnapshotFullRefresh marketData, SessionID sessionID) throws FieldNotFound {

    Symbol symbol = marketData.getSymbol();

    int count = marketData.getGroupCount(NoMDEntries.FIELD);
    for (int i = 1; i <= count; i++) {

        Group group = marketData.getGroup(i, NoMDEntries.FIELD);
        char entryType = group.getChar(MDEntryType.FIELD);
        if (entryType == MDEntryType.BID || entryType == MDEntryType.OFFER) {

            double price = group.getDouble(MDEntryPx.FIELD);
            double size = group.getDouble(MDEntrySize.FIELD);
            Date time = group.getUtcTimeOnly(MDEntryTime.FIELD);

            Calendar calendar = Calendar.getInstance();
            calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
            calendar = DateUtils.truncate(calendar, Calendar.DATE);
            Date date = new Date(calendar.getTimeInMillis() + time.getTime());

            String tickerId = symbol.getValue();
            switch (entryType) {
            case MDEntryType.BID:

                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("{} BID {}@{}", symbol.getValue(), size, price);
                }// www . ja v  a2s  .c o  m

                BidVO bidVO = new BidVO(tickerId, FeedType.DC.name(), date, price, (int) size);
                this.serverEngine.sendEvent(bidVO);
                break;
            case MDEntryType.OFFER:

                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("{} ASK {}@{}", symbol.getValue(), size, price);
                }

                AskVO askVO = new AskVO(tickerId, FeedType.DC.name(), date, price, (int) size);

                this.serverEngine.sendEvent(askVO);
                break;
            }
        }
    }
}

From source file:edu.stanford.muse.email.WebPageThumbnail.java

/** create a dataset and emit top level pages */
public static void fetchWebPageThumbnails(String rootDir, String prefix, List<Document> allDocs,
        boolean archivedPages, int limit) throws IOException, JSONException {
    List<LinkInfo> links = EmailUtils.getLinksForDocs(allDocs);

    // compute map of url -> doc
    Map<String, List<Document>> fmap = new LinkedHashMap<String, List<Document>>();
    for (LinkInfo li : links) {
        List<Document> lis = fmap.get(li);
        if (lis == null) {
            lis = new ArrayList<Document>();
            fmap.put(li.link, lis);// w ww  .j  a  v a  2s . c  o m
        }
        lis.add(li.doc);
    }

    List<Blob> allDatas = new ArrayList<Blob>();
    BlobStore data_store = new BlobStore(rootDir + File.separator + "blobs");

    int successes = 0;
    outer: for (String url : fmap.keySet()) {
        List<Document> lis = fmap.get(url);
        for (Document doc : lis) {
            if (doc instanceof DatedDocument) {
                String targetURL = url;
                DatedDocument dd = ((DatedDocument) doc);
                if (archivedPages) {
                    Calendar c = new GregorianCalendar();
                    c.setTime(((DatedDocument) doc).date);
                    String archiveDate = c.get(Calendar.YEAR) + String.format("%02d", c.get(Calendar.MONTH))
                            + String.format("%02d", c.get(Calendar.DATE)) + "120000";
                    // color dates
                    targetURL = "http://web.archive.org/" + archiveDate + "/" + url;
                }

                try {
                    // the name is just the URL, so that different URLs have a different Data
                    String sanitizedURL = Util.sanitizeFolderName(targetURL); // targetURL is not really a folder name, but all we want is to convert the '/' to __
                    WebPageThumbnail wpt = new WebPageThumbnail(sanitizedURL + ".png", dd); /// 10K as a dummy ??
                    boolean targetURLIsHTML = !(Util.is_image_filename(targetURL)
                            || Util.is_office_document(targetURL) || Util.is_pdf_filename(targetURL));

                    if (!data_store.contains(wpt)) {
                        // download the html page first
                        HttpClient client = new HttpClient();
                        String tmpFile = File.createTempFile("webtn.", ".tmp").getAbsolutePath();
                        GetMethod get = new GetMethod(targetURL);
                        int statusCode = client.executeMethod(get);
                        if (statusCode == 200) {
                            // execute method and handle any error responses.
                            InputStream in = get.getResponseBodyAsStream();
                            // Process the data from the input stream.
                            Util.copy_stream_to_file(in, tmpFile);
                            get.releaseConnection();

                            if (targetURLIsHTML) {
                                // use jtidy to convert it to xhtml
                                String tmpXHTMLFile = File.createTempFile("webtn.", ".xhtml").getAbsolutePath();
                                Tidy tidy = new Tidy(); // obtain a new Tidy instance
                                tidy.setXHTML(true); // set desired config options using tidy setters
                                InputStream is = new FileInputStream(tmpFile);
                                OutputStream os = new FileOutputStream(tmpXHTMLFile);
                                tidy.parse(is, os); // run tidy, providing an input and output stream
                                try {
                                    is.close();
                                } catch (Exception e) {
                                }
                                try {
                                    os.close();
                                } catch (Exception e) {
                                }

                                // use xhtmlrenderer to convert it to a png
                                File pngFile = File.createTempFile("webtn.", ".png");
                                BufferedImage buff = null;
                                String xhtmlURL = new File(tmpXHTMLFile).toURI().toString();
                                buff = Graphics2DRenderer.renderToImage(xhtmlURL, 640, 480);
                                ImageIO.write(buff, "png", pngFile);
                                data_store.add(wpt, new FileInputStream(pngFile));
                            } else {
                                data_store.add(wpt, new FileInputStream(tmpFile));
                                if (Util.is_pdf_filename(targetURL))
                                    data_store.generate_thumbnail(wpt);
                            }
                            successes++;
                            if (successes == limit)
                                break outer;
                        } else
                            log.info("Unable to GET targetURL " + targetURL + " status code = " + statusCode);
                    }

                    allDatas.add(wpt);
                } catch (Exception e) {
                    log.warn(Util.stackTrace(e));
                } catch (Error e) {
                    log.warn(Util.stackTrace(e));
                }
            }

            if (!archivedPages)
                break; // only need to show one page if we're not showing archives
        }
    }
    BlobSet bs = new BlobSet(rootDir, allDatas, data_store);
    bs.generate_top_level_page(prefix);
}

From source file:org.sasabus.export2Freegis.network.SubscriptionManager.java

public boolean subscribe() throws IOException {
    for (int i = 0; i < SUBFILEARRAY.length; ++i) {
        Scanner sc = new Scanner(new File(SUBFILEARRAY[i]));
        String subscriptionstring = "";
        while (sc.hasNextLine()) {
            subscriptionstring += sc.nextLine();
        }/*from  w  ww.  java  2  s .c  o  m*/
        sc.close();
        SimpleDateFormat date_date = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat date_time = new SimpleDateFormat("HH:mm:ssZ");

        Date d = new Date();
        String timestamp = date_date.format(d) + "T" + date_time.format(d);
        timestamp = timestamp.substring(0, timestamp.length() - 2) + ":"
                + timestamp.substring(timestamp.length() - 2);
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        c.add(Calendar.DATE, 1);
        d = c.getTime();
        String valid_until = date_date.format(d) + "T" + date_time.format(d);
        valid_until = valid_until.substring(0, valid_until.length() - 2) + ":"
                + valid_until.substring(valid_until.length() - 2);
        subscriptionstring = subscriptionstring.replaceAll(":timestamp_valid", valid_until);
        subscriptionstring = subscriptionstring.replaceAll(":timestamp", timestamp);

        String requestString = "http://" + this.address + ":" + this.portnumber_sender
                + "/TmEvNotificationService/gms/subscription.xml";

        HttpPost subrequest = new HttpPost(requestString);

        StringEntity requestEntity = new StringEntity(subscriptionstring,
                ContentType.create("text/xml", "ISO-8859-1"));

        CloseableHttpClient httpClient = HttpClients.createDefault();

        subrequest.setEntity(requestEntity);

        CloseableHttpResponse response = httpClient.execute(subrequest);

        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            try {
                System.out.println("Stauts Response: " + response.getStatusLine().getStatusCode());
                System.out.println("Status Phrase: " + response.getStatusLine().getReasonPhrase());
                HttpEntity responseEntity = response.getEntity();
                if (responseEntity != null) {
                    String responsebody = EntityUtils.toString(responseEntity);
                    System.out.println(responsebody);
                }
            } finally {
                response.close();
                httpClient.close();
            }
            return false;
        }
        System.out.println("Subscription of " + SUBFILEARRAY[i]);
    }
    return true;

}

From source file:org.openmrs.module.usagestatistics.web.view.chart.DateRangeChartView.java

@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    UsageStatisticsService svc = Context.getService(UsageStatisticsService.class);
    List<Object[]> stats = svc.getDateRangeStats(null, null, null);

    String xAxisLabel = ContextProvider.getMessage("usagestatistics.chart.date");
    String yAxisLabel = ContextProvider.getMessage("usagestatistics.chart.records");
    String seriesUsages = ContextProvider.getMessage("usagestatistics.results.views");
    String seriesEncounters = ContextProvider.getMessage("usagestatistics.results.encounters");
    String seriesUpdates = ContextProvider.getMessage("usagestatistics.results.updates");

    // Get minimum date value in returned statistics
    Date minDate = (stats.size() > 0) ? (Date) (stats.get(0)[0]) : getFromDate();
    if (minDate.getTime() > getFromDate().getTime()) // Min date must be at least a week ago
        minDate = getFromDate();/* ww  w .j  av a2s.c  o  m*/
    // Maximum date defaults to today
    Date maxDate = (getUntilDate() != null) ? getUntilDate() : new Date();

    // Build a zeroized dataset of all dates in range       
    TimeTableXYDataset dataset = new TimeTableXYDataset();
    Calendar cal = new GregorianCalendar();
    cal.setTime(minDate);
    while (cal.getTime().getTime() <= maxDate.getTime()) {
        Date day = cal.getTime();
        dataset.add(new Day(day), 0, seriesUsages, false);
        dataset.add(new Day(day), 0, seriesEncounters, false);
        dataset.add(new Day(day), 0, seriesUpdates, false);
        cal.add(Calendar.DATE, 1);
    }

    // Update the dates for which we have statistics
    for (Object[] row : stats) {
        Date date = (Date) row[0];
        int usages = ((Number) row[1]).intValue();
        int encounters = ((Number) row[2]).intValue();
        int updates = ((Number) row[3]).intValue();
        dataset.add(new Day(date), usages, seriesUsages, false);
        dataset.add(new Day(date), encounters, seriesEncounters, false);
        dataset.add(new Day(date), updates, seriesUpdates, false);
    }
    dataset.setDomainIsPointsInTime(true);

    JFreeChart chart = ChartFactory.createXYLineChart(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, false, false);
    DateAxis xAxis = new DateAxis(xAxisLabel);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(xAxis);

    return chart;
}

From source file:com.googlecode.jsfFlex.shared.util.JSONConverter.java

public static JSONArray convertJavaDateToASDateConstructorArguments(Calendar toConvert) {
    JSONArray dateConstructorArguments = new JSONArray();

    dateConstructorArguments.put(toConvert.get(Calendar.YEAR));
    dateConstructorArguments.put(toConvert.get(Calendar.MONTH));
    dateConstructorArguments.put(toConvert.get(Calendar.DATE));
    dateConstructorArguments.put(toConvert.get(Calendar.HOUR_OF_DAY));
    dateConstructorArguments.put(toConvert.get(Calendar.MINUTE));
    dateConstructorArguments.put(toConvert.get(Calendar.SECOND));
    dateConstructorArguments.put(toConvert.get(Calendar.MILLISECOND));

    return dateConstructorArguments;
}

From source file:gr.abiss.calipso.plugins.state.ep.ExampleEp1BusinessLogicPlugin.java

/**
 * @see gr.abiss.calipso.plugins.state.AbstractStatePlugin#execute(gr.abiss.calipso.CalipsoService, gr.abiss.calipso.domain.History)
 *//*from   ww w  .  j a  v a 2s  .c o m*/
@Override
public Serializable executePostStateChange(CalipsoService calipsoService, History history) {

    logger.debug("execute called");
    // now move on with checks and calculations
    Item item = history.getParent();
    // if the first option is selected, i.e. "active"

    if (item.getCusInt03().intValue() != 1) {
        String comment = "\n ?   ? (The GoO Account is blocked).";
        addRejectionCause(calipsoService, history, item, comment);
    }

    // update cusTim05
    item.setCusTim05(item.getCusTim01());
    history.setCusTim05(item.getCusTim01());
    // update cusDbl11 period
    Calendar endPeriod = Calendar.getInstance();
    endPeriod.setTime(item.getCusTim02());
    endPeriod.add(Calendar.DATE, 1);

    int monthDiff = DateUtils.getMonthDifference(item.getCusTim01(), endPeriod.getTime());
    if (monthDiff <= 0 || item.getCusTim01().compareTo(item.getCusTim02()) > 0) {
        String comment = "\n ? ? ? ?     ?? ? ?, ?   ??  ?   (Production start date corresponding to this GoO must be earlier than its production end date).";
        addRejectionCause(calipsoService, history, item, comment);
    }
    Double cusDbl11 = new Double(monthDiff);
    item.setCusDbl11(cusDbl11);
    history.setCusDbl11(cusDbl11);

    // update cusTim03
    Date now = item.getTimeStamp();
    Calendar calendarCusTim02 = Calendar.getInstance();
    calendarCusTim02.setTime(item.getCusTim02());
    calendarCusTim02.add(Calendar.DATE, 30);
    item.setCusTim03(calendarCusTim02.getTime());
    history.setCusTim03(calendarCusTim02.getTime());

    // reset and go for cusTim04
    calendarCusTim02.setTime(item.getCusTim02());
    calendarCusTim02.add(Calendar.YEAR, 1);
    item.setCusTim04(calendarCusTim02.getTime());
    history.setCusTim04(calendarCusTim02.getTime());

    // check if the item was submitted during the allowed period
    // cusTim04 >= timeStamp >= cusTim03
    if (!(item.getCusTim04().compareTo(now) >= 0 && item.getCusTim03().compareTo(now) <= 0)) {
        String comment = "\no    ? (The submission date is not within the valid submission period).";
        addRejectionCause(calipsoService, history, item, comment);
    }

    // update cusTim06
    item.setCusTim06(calendarCusTim02.getTime());
    history.setCusTim06(calendarCusTim02.getTime());

    markRejectedIfErrors(history, item);

    calipsoService.updateHistory(history);
    calipsoService.updateItem(item, history.getLoggedBy(), false);
    return null;
}

From source file:KalendarDialog.java

private void setDayForDisplay(Calendar now) {
    int currentDay = now.get(Calendar.DATE);
    now.add(Calendar.DAY_OF_MONTH, -(now.get(Calendar.DATE) - 1)); //
    int startIndex = now.get(Calendar.DAY_OF_WEEK) - 1; //
    int year = now.get(Calendar.YEAR); //
    int month = now.get(Calendar.MONTH) + 1; //
    int lastDay = this.getLastDayOfMonth(year, month); //
    int endIndex = startIndex + lastDay - 1; //
    int startday = 1;
    for (int i = 0; i < 42; i++) {
        Color temp = days[i].getBackground();
        if (temp.equals(display.getSystemColor(SWT.COLOR_BLUE))) {

            days[i].setBackground(display.getSystemColor(SWT.COLOR_WHITE));
        }//from   w w  w.  j  a v a  2 s . c  o m
    }
    for (int i = 0; i < 42; i++) {
        if (i >= startIndex && i <= endIndex) {
            days[i].setText("" + startday);
            if (startday == currentDay) {

                days[i].setBackground(display.getSystemColor(SWT.COLOR_BLUE)); //
            }
            startday++;
        } else {
            days[i].setText("");
        }
    }

}