Search in sources :

Example 51 with DateFormat

use of java.text.DateFormat in project stashbot by palantir.

the class BuildSuccessReportingServlet method getSuccessStatus.

private BuildStatus getSuccessStatus(Repository repo, JobTemplate jt, State state, long buildNumber, String buildHead) throws SQLException {
    Date now = new Date(java.lang.System.currentTimeMillis());
    DateFormat df = DateFormat.getDateInstance();
    // key will be the jenkins name
    String key = jt.getBuildNameFor(repo);
    String name = key + " (build " + Long.toString(buildNumber) + ")";
    String description = "Build " + Long.toString(buildNumber) + " " + state.toString() + " at " + df.format(now);
    String url = getJenkinsUrl(repo, jt, buildNumber);
    BuildStatus bs = new InternalBuildStatus(state, name, name, url, description, now);
    return bs;
}
Also used : DateFormat(java.text.DateFormat) BuildStatus(com.atlassian.stash.build.BuildStatus) InternalBuildStatus(com.atlassian.stash.internal.build.InternalBuildStatus) Date(java.sql.Date) InternalBuildStatus(com.atlassian.stash.internal.build.InternalBuildStatus)

Example 52 with DateFormat

use of java.text.DateFormat in project processing by processing.

the class DetailPanel method setContribution.

public void setContribution(Contribution contrib) {
    this.contrib = contrib;
    if (contrib.isSpecial()) {
        JLabel iconLabel = new JLabel(foundationIcon);
        iconLabel.setBorder(new EmptyBorder(4, 7, 7, 7));
        iconLabel.setVerticalAlignment(SwingConstants.TOP);
        add(iconLabel, BorderLayout.WEST);
    }
    // Avoid ugly synthesized bold
    Font boldFont = ManagerFrame.SMALL_BOLD;
    String fontFace = "<font face=\"" + boldFont.getName() + "\">";
    StringBuilder desc = new StringBuilder();
    desc.append("<html><body>" + fontFace);
    if (contrib.getUrl() == null) {
        desc.append(contrib.getName());
    } else {
        desc.append("<a href=\"" + contrib.getUrl() + "\">" + contrib.getName() + "</a>");
    }
    desc.append("</font> ");
    String prettyVersion = contrib.getPrettyVersion();
    if (prettyVersion != null) {
        desc.append(prettyVersion);
    }
    desc.append(" <br/>");
    String authorList = contrib.getAuthorList();
    if (authorList != null && !authorList.isEmpty()) {
        desc.append(toHtmlLinks(contrib.getAuthorList()));
    }
    desc.append("<br/><br/>");
    if (contrib.isDeletionFlagged()) {
        desc.append(REMOVE_RESTART_MESSAGE);
    } else if (contrib.isRestartFlagged()) {
        desc.append(INSTALL_RESTART_MESSAGE);
    } else if (contrib.isUpdateFlagged()) {
        desc.append(UPDATE_RESTART_MESSAGE);
    } else {
        String sentence = contrib.getSentence();
        if (sentence == null || sentence.isEmpty()) {
            sentence = String.format("<i>%s</i>", Language.text("contrib.errors.description_unavailable"));
        } else {
            sentence = sanitizeHtmlTags(sentence);
            sentence = toHtmlLinks(sentence);
        }
        desc.append(sentence);
    }
    long lastUpdatedUTC = contrib.getLastUpdated();
    if (lastUpdatedUTC != 0) {
        DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
        Date lastUpdatedDate = new Date(lastUpdatedUTC);
        if (prettyVersion != null) {
            desc.append(", ");
        }
        desc.append("Last Updated on " + dateFormatter.format(lastUpdatedDate));
    }
    desc.append("</body></html>");
    description = desc.toString();
    descriptionPane.setText(description);
    if (contribListing.hasUpdates(contrib) && contrib.isCompatible(Base.getRevision())) {
        StringBuilder versionText = new StringBuilder();
        versionText.append("<html><body><i>");
        if (contrib.isUpdateFlagged() || contrib.isDeletionFlagged()) {
            // versionText.append("To finish an update, reinstall this contribution after restarting.");
            ;
        } else {
            String latestVersion = contribListing.getLatestPrettyVersion(contrib);
            if (latestVersion != null) {
                versionText.append("New version (" + latestVersion + ") available.");
            } else {
                versionText.append("New version available.");
            }
        }
        versionText.append("</i></body></html>");
        notificationLabel.setText(versionText.toString());
        notificationLabel.setVisible(true);
    } else {
        notificationLabel.setText("");
        notificationLabel.setVisible(false);
    }
    updateButton.setEnabled(true);
    if (contrib != null) {
        updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || updateInProgress);
    }
    if (contrib.isDeletionFlagged()) {
        installRemoveButton.setText(undoText);
    } else if (contrib.isInstalled()) {
        installRemoveButton.setText(removeText);
        installRemoveButton.setVisible(true);
        installRemoveButton.setEnabled(!contrib.isUpdateFlagged());
        reorganizePaneComponents();
    } else {
        installRemoveButton.setText(installText);
    }
    contextMenu.removeAll();
    if (contrib.isInstalled()) {
        contextMenu.add(openFolder);
        setComponentPopupMenu(contextMenu);
    } else {
        setComponentPopupMenu(null);
    }
    if (!contrib.isCompatible(Base.getRevision())) {
        blurContributionPanel(this);
    }
}
Also used : DateFormat(java.text.DateFormat) EmptyBorder(javax.swing.border.EmptyBorder) Date(java.util.Date)

Example 53 with DateFormat

use of java.text.DateFormat in project ratpack by ratpack.

the class GradleVersion method formatBuildTime.

private String formatBuildTime(Date buildTime) {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    return format.format(buildTime);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 54 with DateFormat

use of java.text.DateFormat in project android-saripaar by ragunathjawahar.

the class FutureRule method isValid.

@Override
public boolean isValid(final String dateString) {
    DateFormat dateFormat = getDateFormat();
    Date parsedDate = null;
    try {
        parsedDate = dateFormat.parse(dateString);
    } catch (ParseException ignored) {
    }
    Date now = new Date();
    return parsedDate != null && parsedDate.after(now);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException) Date(java.util.Date)

Example 55 with DateFormat

use of java.text.DateFormat in project robolectric by robolectric.

the class RoboCookieManager method getExpiration.

private Date getExpiration(String field) {
    int equalsIndex = field.indexOf("=");
    if (equalsIndex < 0) {
        return null;
    }
    String date = field.substring(equalsIndex + 1);
    try {
        DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
        return dateFormat.parse(date);
    } catch (ParseException e) {
    // No-op. Try to inferFromValue additional date formats.
    }
    try {
        DateFormat dateFormat = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss zzz");
        return dateFormat.parse(date);
    } catch (ParseException e) {
        // Was not parsed by any date formatter.
        return null;
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

DateFormat (java.text.DateFormat)646 SimpleDateFormat (java.text.SimpleDateFormat)486 Date (java.util.Date)315 ParseException (java.text.ParseException)132 Calendar (java.util.Calendar)78 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)48 IOException (java.io.IOException)43 File (java.io.File)31 HashMap (java.util.HashMap)27 GregorianCalendar (java.util.GregorianCalendar)24 TimeZone (java.util.TimeZone)23 Locale (java.util.Locale)18 Timestamp (java.sql.Timestamp)17 List (java.util.List)14 InputStream (java.io.InputStream)12 DateTime (org.joda.time.DateTime)11 Map (java.util.Map)10 Matcher (java.util.regex.Matcher)8 TestBean (org.springframework.tests.sample.beans.TestBean)8