Example usage for java.text DateFormat SHORT

List of usage examples for java.text DateFormat SHORT

Introduction

In this page you can find the example usage for java.text DateFormat SHORT.

Prototype

int SHORT

To view the source code for java.text DateFormat SHORT.

Click Source Link

Document

Constant for short style pattern.

Usage

From source file:it.jugpadova.blo.EventBo.java

/**
 * Ajax method for a full text search on events.
 *
 * @param searchQuery The text to search
 * @param maxResults The max number of results. No limit if maxResults <= 0.
 *//*from  w  w  w.j  av  a  2s  .c om*/
@RemoteMethod
public void fullTextSearch(String searchQuery, boolean pastEvents, String locale, int maxResults) {
    if (StringUtils.isNotBlank(searchQuery)) {
        WebContext wctx = WebContextFactory.get();
        HttpServletRequest req = wctx.getHttpServletRequest();
        ScriptSession session = wctx.getScriptSession();
        Util util = new Util(session);
        java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT,
                new Locale(locale));
        java.lang.String baseUrl = "http://" + req.getServerName() + ":" + req.getServerPort()
                + req.getContextPath();
        List<Event> events = null;
        try {
            events = this.search(searchQuery, pastEvents, maxResults);
        } catch (ParseException pex) {
            logger.info("Error parsing query: " + searchQuery);
        } catch (Exception ex) {
            logger.error("Error searching events", ex);
        }
        if (events != null && events.size() > 0) {
            StringBuilder sb = new StringBuilder();
            for (Event event : events) {
                sb.append("<div>\n");
                sb.append("<div class=\"eventDate\">").append(dateFormat.format(event.getStartDate()))
                        .append("</div>");
                if (event.getOwner() != null) {
                    sb.append("<div class=\"eventSignature\"><a href=\"")
                            .append(event.getOwner().getJug().getWebSiteUrl()).append("\">")
                            .append(event.getOwner().getJug().getName()).append("</a></div>");
                }
                sb.append("<div class=\"eventContent\"><a href=\"").append(baseUrl).append("/event/")
                        .append(event.getId()).append("\">").append(event.getTitle()).append("</a></div>");
                sb.append("</div>\n");
            }
            util.setValue("content_textSearch_result", sb.toString(), false);
        } else {
            util.setValue("content_textSearch_result", "", false);
        }
    }
}

From source file:com.jeeframework.util.validate.GenericTypeValidator.java

/**
 *  <p>/*from   www. ja  va 2 s .  co  m*/
 *
 *  Checks if the field is a valid date. The <code>Locale</code> is used
 *  with <code>java.text.DateFormat</code>. The setLenient method is set to
 *  <code>false</code> for all.</p>
 *
 *@param  value   The value validation is being performed on.
 *@param  locale  The Locale to use to parse the date (system default if
 *      null)
 *@return the converted Date value.
 */
public static Date formatDate(String value, Locale locale) {
    Date date = null;

    if (value == null) {
        return null;
    }

    try {
        DateFormat formatter = null;
        if (locale != null) {
            formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
        }

        formatter.setLenient(false);

        date = formatter.parse(value);
    } catch (ParseException e) {
        // Bad date so return null
        Log log = LogFactory.getLog(GenericTypeValidator.class);
        if (log.isDebugEnabled()) {
            log.debug("Date parse failed value=[" + value + "], " + "locale=[" + locale + "] " + e);
        }
    }

    return date;
}

From source file:org.yccheok.jstock.gui.JTableUtilities.java

/**
 * Sets the editor/renderer for Date objects to provided JTable, for the specified column.
 * @param table JTable to set up//  w w w. j a  v  a2 s. c  o m
 * @param row Column to apply
 */
public static void setDateEditorAndRendererForRow(JTable table, int row) {
    final TableColumn column = table.getColumnModel().getColumn(row);
    // SwingX's. Pretty but buggy.
    //column.setCellEditor(new DatePickerCellEditor());
    column.setCellEditor(new DateFieldTableEditor());
    final DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
    column.setCellRenderer(new DateRendererDecoratorEx(column.getCellRenderer(), format));
}

From source file:no.firestorm.weathernotificatonservice.WeatherNotificationService.java

/**
 * Display a notification with temperature
 * /*from  ww w .  j  a v a 2s. c  o m*/
 * @param weather
 *            Weather element to with data to be shown in notification, if
 *            null a message for that say that this station does not provide
 *            data will be shown
 */
private void makeNotification(WeatherElement weather) {
    int tickerIcon, contentIcon;
    CharSequence tickerText, contentTitle, contentText, contentTime;
    final DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
    long when;
    Float temperatureF = null;
    if (weather != null) {
        // Has data
        final WeatherElement temperature = weather;
        // Find name
        final String stationName = WeatherNotificationSettings.getStationName(WeatherNotificationService.this);

        // Find icon
        tickerIcon = TempToDrawable.getDrawableFromTemp(Float.valueOf(temperature.getValue()));
        contentIcon = tickerIcon;
        // Set title
        tickerText = stationName;
        contentTitle = stationName;
        contentTime = df.format(temperature.getDate());
        when = temperature.getDate().getTime();

        final Context context = WeatherNotificationService.this;
        temperatureF = new Float(temperature.getValue());
        contentText = String.format("%s %.1f C", context.getString(R.string.temperatur_),
                new Float(temperature.getValue()));

        updateAlarm(weather);

    } else {
        // No data
        contentIcon = android.R.drawable.stat_notify_error;
        final Context context = WeatherNotificationService.this;
        contentTime = df.format(new Date());
        when = (new Date()).getTime();
        tickerText = context.getText(R.string.no_available_data);
        contentTitle = context.getText(R.string.no_available_data);
        contentText = context.getString(R.string.try_another_station);
        tickerIcon = android.R.drawable.stat_notify_error;

    }

    makeNotification(tickerIcon, contentIcon, tickerText, contentTitle, contentText, contentTime, when,
            temperatureF);

}

From source file:org.nuxeo.ecm.webapp.search.SearchResultsBean.java

public String downloadCSV() throws ClientException {
    try {/*from  w  w w  . j a  v  a2  s  .co m*/
        if (newProviderName == null) {
            throw new ClientException("providerName not set");
        }
        PagedDocumentsProvider provider = getProvider(newProviderName);
        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();
        response.setContentType("text/csv");
        response.setHeader("Content-Disposition", "attachment; filename=\"search_results.csv\"");

        char separator = Framework.getProperty("org.nuxeo.ecm.webapp.search.csv.separator", ",").charAt(0);
        char quotechar = Framework.getProperty("org.nuxeo.ecm.webapp.search.csv.quotechar", "\"").charAt(0);
        String endOfLine = Framework.getProperty("org.nuxeo.ecm.webapp.search.csv.endofline", "\n");
        CSVWriter writer = new CSVWriter(response.getWriter(), separator, quotechar, endOfLine);

        List<FieldWidget> widgetList = searchColumns.getResultColumns();
        Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);

        String[] columnNames = new String[widgetList.size()];
        int i = 0;
        for (FieldWidget widget : widgetList) {
            String columnName = resourcesAccessor.getMessages().get(widget.getLabel());
            columnNames[i++] = columnName;
        }
        writer.writeNext(columnNames);

        // GR dump all pages... why not, but we need to restore current page
        // number.
        int currentPage = provider.getCurrentPageIndex();
        int pageCount = provider.getNumberOfPages();
        for (int page = 0; page < pageCount; page++) {
            DocumentModelList docModelList = provider.getPage(page);
            for (DocumentModel docModel : docModelList) {
                String[] columns = new String[widgetList.size()];
                i = 0;
                for (FieldWidget widget : widgetList) {
                    String fieldSchema = widget.getSchemaName();
                    String fieldName = widget.getFieldName();
                    Object value = docModel.getProperty(fieldSchema, fieldName);

                    if (fieldSchema.equals("dublincore") && fieldName.equals("title")) {
                        value = DocumentModelFunctions.titleOrId(docModel);
                    } else if (fieldSchema.equals("ecm") && fieldName.equals("primaryType")) {
                        value = docModel.getType();
                    } else if (fieldSchema.equals("ecm") && fieldName.equals("currentLifeCycleState")) {
                        value = docModel.getCurrentLifeCycleState();
                    } else {
                        value = docModel.getProperty(fieldSchema, fieldName);
                    }
                    String stringValue;
                    if (value == null) {
                        stringValue = "";
                    } else if (value instanceof GregorianCalendar) {
                        GregorianCalendar gValue = (GregorianCalendar) value;
                        stringValue = df.format(gValue.getTime());
                    } else {
                        stringValue = String.valueOf(value);
                    }
                    columns[i++] = stringValue;
                }
                writer.writeNext(columns);
            }
        }
        writer.close();
        response.flushBuffer();
        FacesContext.getCurrentInstance().responseComplete();
        // restoring current page
        provider.getPage(currentPage);
    } catch (IOException e) {
        throw new ClientException("download csv failed", e);
    }
    return null;
}

From source file:org.ejbca.core.model.ra.ExtendedInformation.java

/** Implementation of UpgradableDataHashMap function upgrade. */
public void upgrade() {
    if (Float.compare(LATEST_VERSION, getVersion()) != 0) {
        // New version of the class, upgrade
        String msg = intres.getLocalizedMessage("endentity.extendedinfoupgrade", new Float(getVersion()));
        log.info(msg);/*from   ww w .j a v  a  2  s  . com*/

        if (data.get(SUBJECTDIRATTRIBUTES) == null) {
            data.put(SUBJECTDIRATTRIBUTES, "");
        }
        if (data.get(MAXFAILEDLOGINATTEMPTS) == null) {
            setMaxLoginAttempts(DEFAULT_MAXLOGINATTEMPTS);
        }
        if (data.get(REMAININGLOGINATTEMPTS) == null) {
            setRemainingLoginAttempts(DEFAULT_REMAININGLOGINATTEMPTS);
        }
        // In EJBCA 4.0.0 we changed the date format
        if (getVersion() < 3) {
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT,
                    Locale.US);
            final FastDateFormat newDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm");
            try {
                final String oldCustomStartTime = getCustomData(ExtendedInformation.CUSTOM_STARTTIME);
                if (!isEmptyOrRelative(oldCustomStartTime)) {
                    // We use an absolute time format, so we need to upgrade
                    final String newCustomStartTime = newDateFormat
                            .format(oldDateFormat.parse(oldCustomStartTime));
                    setCustomData(ExtendedInformation.CUSTOM_STARTTIME, newCustomStartTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + ExtendedInformation.CUSTOM_STARTTIME + " from \""
                                + oldCustomStartTime + "\" to \"" + newCustomStartTime
                                + "\" in ExtendedInformation.");
                    }
                }
            } catch (ParseException e) {
                log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_STARTTIME
                        + " in extended user information.", e);
            }
            try {
                final String oldCustomEndTime = getCustomData(ExtendedInformation.CUSTOM_ENDTIME);
                if (!isEmptyOrRelative(oldCustomEndTime)) {
                    // We use an absolute time format, so we need to upgrade
                    final String newCustomEndTime = newDateFormat.format(oldDateFormat.parse(oldCustomEndTime));
                    setCustomData(ExtendedInformation.CUSTOM_ENDTIME, newCustomEndTime);
                    if (log.isDebugEnabled()) {
                        log.debug(
                                "Upgraded " + ExtendedInformation.CUSTOM_ENDTIME + " from \"" + oldCustomEndTime
                                        + "\" to \"" + newCustomEndTime + "\" in ExtendedInformation.");
                    }
                }
            } catch (ParseException e) {
                log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_ENDTIME
                        + " in extended user information.", e);
            }
        }
        // In 4.0.2 we further specify the storage format by saying that UTC TimeZone is implied instead of local server time
        if (getVersion() < 4) {
            final String[] timePatterns = { "yyyy-MM-dd HH:mm" };
            final String oldStartTime = getCustomData(ExtendedInformation.CUSTOM_STARTTIME);
            if (!isEmptyOrRelative(oldStartTime)) {
                try {
                    final String newStartTime = ValidityDate
                            .formatAsUTC(DateUtils.parseDateStrictly(oldStartTime, timePatterns));
                    setCustomData(ExtendedInformation.CUSTOM_STARTTIME, newStartTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + ExtendedInformation.CUSTOM_STARTTIME + " from \"" + oldStartTime
                                + "\" to \"" + newStartTime + "\" in EndEntityProfile.");
                    }
                } catch (ParseException e) {
                    log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_STARTTIME
                            + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).",
                            e);
                }
            }
            final String oldEndTime = getCustomData(ExtendedInformation.CUSTOM_ENDTIME);
            if (!isEmptyOrRelative(oldEndTime)) {
                // We use an absolute time format, so we need to upgrade
                try {
                    final String newEndTime = ValidityDate
                            .formatAsUTC(DateUtils.parseDateStrictly(oldEndTime, timePatterns));
                    setCustomData(ExtendedInformation.CUSTOM_ENDTIME, newEndTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + ExtendedInformation.CUSTOM_ENDTIME + " from \"" + oldEndTime
                                + "\" to \"" + newEndTime + "\" in EndEntityProfile.");
                    }
                } catch (ParseException e) {
                    log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_ENDTIME
                            + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).",
                            e);
                }
            }
        }
        data.put(VERSION, new Float(LATEST_VERSION));
    }
}

From source file:org.sakaiproject.tool.gradebook.ui.SpreadsheetUploadBean.java

public void init() {

    localGradebook = getGradebook();/*www  .  j  a v  a  2  s. c  om*/

    initializeRosterMap();

    if (assignment == null) {
        if (assignmentId != null) {
            assignment = getGradebookManager().getAssignment(assignmentId);
        }
        if (assignment == null) {
            // it is a new assignment
            assignment = new Assignment();
            assignment.setReleased(true);
        }
    }

    // initialization; shouldn't enter here after category drop down changes
    if (assignmentCategory == null
            && !getLocalizedString("cat_unassigned").equalsIgnoreCase(selectedCategory)) {
        Category assignCategory = assignment.getCategory();
        if (assignCategory != null) {
            selectedCategory = assignCategory.getId().toString();
            selectedCategoryDropsScores = assignCategory.isDropScores();
            assignCategory.setAssignmentList(retrieveCategoryAssignmentList(assignCategory));
            assignmentCategory = assignCategory;
        } else {
            selectedCategory = getLocalizedString("cat_unassigned");
        }
    }

    if (selectedCategory == null)
        selectedCategory = AssignmentBean.UNASSIGNED_CATEGORY;
    categoriesSelectList = new ArrayList();
    //create comma seperate string representation of the list of EC categories
    extraCreditCategories = new ArrayList();
    // The first choice is always "Unassigned"
    categoriesSelectList.add(
            new SelectItem(AssignmentBean.UNASSIGNED_CATEGORY, FacesUtil.getLocalizedString("cat_unassigned")));
    List gbCategories = getViewableCategories();
    if (gbCategories != null && gbCategories.size() > 0) {
        Iterator catIter = gbCategories.iterator();
        while (catIter.hasNext()) {
            Category cat = (Category) catIter.next();
            categoriesSelectList.add(new SelectItem(cat.getId().toString(), cat.getName()));
            if (cat.isExtraCredit()) {
                extraCreditCategories.add(cat.getId().toString());
            }
        }
    }
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, (new ResourceLoader()).getLocale());
    date_entry_format_description = ((SimpleDateFormat) df).toPattern();

}

From source file:org.agiso.tempel.Tempel.java

/**
 * /*  w w  w  .jav a2  s. c o  m*/
 * 
 * @param properties
 * @throws Exception 
 */
private Map<String, Object> addRuntimeProperties(Map<String, Object> properties) throws Exception {
    Map<String, Object> props = new HashMap<String, Object>();

    // Okrelanie lokalizacji daty/czasu uywanej do wypenienia paramtrw szablonw
    // zawierajcych dat/czas w formatach DateFormat.SHORT, .MEDIUM, .LONG i .FULL:
    Locale date_locale;
    if (properties.containsKey(UP_DATE_LOCALE)) {
        date_locale = LocaleUtils.toLocale((String) properties.get(UP_DATE_LOCALE));
        Locale.setDefault(date_locale);
    } else {
        date_locale = Locale.getDefault();
    }

    TimeZone time_zone;
    if (properties.containsKey(UP_TIME_ZONE)) {
        time_zone = TimeZone.getTimeZone((String) properties.get(UP_DATE_LOCALE));
        TimeZone.setDefault(time_zone);
    } else {
        time_zone = TimeZone.getDefault();
    }

    // Wyznaczanie daty, na podstawie ktrej zostan wypenione parametry szablonw
    // przechowujce dat/czas w formatach DateFormat.SHORT, .MEDIUM, .LONG i .FULL.
    // Odbywa si w oparciu o wartoci parametrw 'date_format' i 'date'. Parametr
    // 'date_format' definiuje format uywany do parsowania acucha reprezentujcego
    // dat okrelon parametrem 'date'. Parametr 'date_format' moe nie by okrelony.
    // W takiej sytuacji uyty jest format DateFormat.LONG aktywnej lokalizacji (tj.
    // systemowej, ktra moe by przedefiniowana przez parametr 'date_locale'), ktry
    // moe by przedefiniowany przez parametry 'date_format_long' i 'time_format_long':
    Calendar calendar = Calendar.getInstance(date_locale);
    if (properties.containsKey(RP_DATE)) {
        String date_string = (String) properties.get(RP_DATE);
        if (properties.containsKey(RP_DATE_FORMAT)) {
            String date_format = (String) properties.get(RP_DATE_FORMAT);
            DateFormat formatter = new SimpleDateFormat(date_format);
            formatter.setTimeZone(time_zone);
            calendar.setTime(formatter.parse(date_string));
        } else if (properties.containsKey(UP_DATE_FORMAT_LONG) && properties.containsKey(UP_TIME_FORMAT_LONG)) {
            // TODO: Zaoenie, e format data-czas jest zoony z acucha daty i czasu rozdzelonych spacj:
            // 'UP_DATE_FORMAT_LONG UP_TIME_FORMAT_LONG'
            DateFormat formatter = new SimpleDateFormat((String) properties.get(UP_DATE_FORMAT_LONG) + " "
                    + (String) properties.get(UP_TIME_FORMAT_LONG), date_locale);
            formatter.setTimeZone(time_zone);
            calendar.setTime(formatter.parse(date_string));
        } else {
            DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG,
                    date_locale);
            formatter.setTimeZone(time_zone);
            calendar.setTime(formatter.parse(date_string));
        }
    }

    // Jeli nie okrelono, wypenianie parametrw przechowujcych poszczeglne
    // skadniki daty, tj. rok, miesic i dzie:
    if (!properties.containsKey(TP_YEAR)) {
        props.put(TP_YEAR, calendar.get(Calendar.YEAR));
    }
    if (!properties.containsKey(TP_MONTH)) {
        props.put(TP_MONTH, calendar.get(Calendar.MONTH));
    }
    if (!properties.containsKey(TP_DAY)) {
        props.put(TP_DAY, calendar.get(Calendar.DAY_OF_MONTH));
    }

    // Jeli nie okrelono, wypenianie parametrw przechowujcych dat i czas w
    // formatach SHORT, MEDIUM, LONG i FULL (na podstawie wyznaczonej lokalizacji):
    Date date = calendar.getTime();
    if (!properties.containsKey(TP_DATE_SHORT)) {
        DateFormat formatter;
        if (properties.containsKey(UP_DATE_FORMAT_SHORT)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_DATE_FORMAT_SHORT), date_locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.SHORT, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_DATE_SHORT, formatter.format(date));
    }
    if (!properties.containsKey(TP_DATE_MEDIUM)) {
        DateFormat formatter;
        if (properties.containsKey(UP_DATE_FORMAT_MEDIUM)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_DATE_FORMAT_MEDIUM), date_locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_DATE_MEDIUM, formatter.format(date));
    }
    if (!properties.containsKey(TP_DATE_LONG)) {
        DateFormat formatter;
        if (properties.containsKey(UP_DATE_FORMAT_LONG)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_DATE_FORMAT_LONG), date_locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.LONG, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_DATE_LONG, formatter.format(date));
    }
    if (!properties.containsKey(TP_DATE_FULL)) {
        DateFormat formatter;
        if (properties.containsKey(UP_DATE_FORMAT_FULL)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_DATE_FORMAT_FULL), date_locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.FULL, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_DATE_FULL, formatter.format(date));
    }

    if (!properties.containsKey(TP_TIME_SHORT)) {
        DateFormat formatter;
        if (properties.containsKey(UP_TIME_FORMAT_SHORT)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_TIME_FORMAT_SHORT), date_locale);
        } else {
            formatter = DateFormat.getTimeInstance(DateFormat.SHORT, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_TIME_SHORT, formatter.format(date));
    }
    if (!properties.containsKey(TP_TIME_MEDIUM)) {
        DateFormat formatter;
        if (properties.containsKey(UP_TIME_FORMAT_MEDIUM)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_TIME_FORMAT_MEDIUM), date_locale);
        } else {
            formatter = DateFormat.getTimeInstance(DateFormat.MEDIUM, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_TIME_MEDIUM, formatter.format(date));
    }
    if (!properties.containsKey(TP_TIME_LONG)) {
        DateFormat formatter;
        if (properties.containsKey(UP_TIME_FORMAT_LONG)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_TIME_FORMAT_LONG), date_locale);
        } else {
            formatter = DateFormat.getTimeInstance(DateFormat.LONG, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_TIME_LONG, formatter.format(date));
    }
    if (!properties.containsKey(TP_TIME_FULL)) {
        DateFormat formatter;
        if (properties.containsKey(UP_TIME_FORMAT_FULL)) {
            formatter = new SimpleDateFormat((String) properties.get(UP_TIME_FORMAT_FULL), date_locale);
        } else {
            formatter = DateFormat.getTimeInstance(DateFormat.FULL, date_locale);
        }
        formatter.setTimeZone(time_zone);
        props.put(TP_TIME_FULL, formatter.format(date));
    }

    return props;
}

From source file:com.appeligo.search.actions.account.BaseAccountAction.java

public String getEarliestSmsTime() {
    if (earliestSmsTime == null) {
        return "8:00 AM";
    }//  w w  w. j av a 2s  .c  o m
    DateFormat format = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
    return format.format(earliestSmsTime);
}

From source file:com.sonyericsson.jenkins.plugins.bfa.CauseManagementHudsonTest.java

/**
 * Makes a modification to a {@link FailureCause} and verifies that the modification list was updated.
 * @throws Exception if something goes wrong
 *//*ww  w  . j  a va  2 s  .  c o m*/
public void testMakeModificationUpdatesModificationList() throws Exception {
    List<FailureCauseModification> modifications = new LinkedList<FailureCauseModification>();
    modifications.add(new FailureCauseModification("unknown", new Date(1)));
    FailureCause cause = new FailureCause(null, "SomeName", "A Description", "Some comment", null, "", null,
            modifications);
    cause.addIndication(new BuildLogIndication("."));
    PluginImpl.getInstance().getKnowledgeBase().addCause(cause);

    WebClient web = createWebClient();
    HtmlPage page = web.goTo(CauseManagement.URL_NAME);

    HtmlTable table = (HtmlTable) page.getElementById("failureCausesTable");

    HtmlAnchor firstCauseLink = (HtmlAnchor) table.getCellAt(1, 0).getFirstChild();
    HtmlPage editPage = firstCauseLink.click();

    HtmlElement modList = editPage.getElementById("modifications");
    int firstNbrOfModifications = modList.getChildNodes().size();

    editPage.getElementByName("_.comment").setTextContent("new comment");

    HtmlForm form = editPage.getFormByName("causeForm");
    submit(form);

    editPage = firstCauseLink.click();
    modList = editPage.getElementById("modifications");
    int secondNbrOfModifications = modList.getChildNodes().size();

    assertEquals(firstNbrOfModifications + 1, secondNbrOfModifications);
    assertStringContains("Latest modification date should be visible", modList.getFirstChild().asText(),
            DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                    .format(cause.getLatestModification().getTime()));
}