Example usage for java.text DateFormat getDateTimeInstance

List of usage examples for java.text DateFormat getDateTimeInstance

Introduction

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

Prototype

public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle) 

Source Link

Document

Gets the date/time formatter with the given date and time formatting styles for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:org.occupycincy.android.OccupyCincyActivity.java

private void processFeed() {

    feedItems = new ArrayList<HashMap<String, String>>();

    // default to Never
    String lastUpdated = getString(R.string.last_updated_never);

    File file = new File(getFullPath(getString(R.string.occupy_feed_file)));
    if (file.exists()) {
        parseOccupyFeed();/*from  w w w  .jav  a 2s  .  c  o  m*/
        lastUpdated = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT)
                .format(new Date(file.lastModified()));
    }

    populateBlogView();

    // display Last Updated: 
    TextView txtLastUpdated = (TextView) findViewById(R.id.txtLastUpdated);
    txtLastUpdated.setText(getString(R.string.last_updated).replace("%TIME%", lastUpdated));

    setLoading(false);
}

From source file:org.apache.sqoop.shell.ShowJobFunction.java

private void displayJob(MJob job) {
    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);

    printlnResource(Constants.RES_SHOW_PROMPT_JOB_INFO, job.getPersistenceId(), job.getName(), job.getEnabled(),
            job.getCreationUser(), formatter.format(job.getCreationDate()), job.getLastUpdateUser(),
            formatter.format(job.getLastUpdateDate()));
    printlnResource(Constants.RES_SHOW_PROMPT_JOB_LID_CID_INFO, job.getLinkId(Direction.FROM),
            job.getConnectorId(Direction.FROM));

    displayConfig(job.getJobConfig(Direction.FROM).getConfigs(),
            client.getConnectorConfigBundle(job.getConnectorId(Direction.FROM)));
    displayConfig(job.getDriverConfig().getConfigs(), client.getDriverConfigBundle());
    displayConfig(job.getJobConfig(Direction.TO).getConfigs(),
            client.getConnectorConfigBundle(job.getConnectorId(Direction.TO)));
}

From source file:es.warp.killthedj.track.AvailableTrack.java

public String getDuration() {
    // TODO library like duration from ruby
    return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(getTime());
}

From source file:liquibase.lockservice.LockServiceEx.java

/**
 * Wait for lock.//from w w  w  . j  a va  2  s  . c  om
 * 
 * @throws LockException
 *             occurs when lock manipulation is failed.
 */
public void waitForLock() throws LockException {

    boolean locked = false;
    long timeToGiveUp = new Date().getTime() + changeLogLockWaitTime;
    while (!locked && new Date().getTime() < timeToGiveUp) {
        locked = acquireLock();
        if (!locked) {
            LOGGER.info("Waiting for changelog lock....");
            try {
                Thread.sleep(changeLogLocRecheckTime);
            } catch (InterruptedException e) {
                noOp();
            }
        }
    }

    if (!locked) {
        DatabaseChangeLogLock[] locks = listLocks();
        String lockedBy;
        if (locks.length > 0) {
            DatabaseChangeLogLock lock = locks[0];
            lockedBy = lock.getLockedBy() + " since " + DateFormat
                    .getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(lock.getLockGranted());
        } else {
            lockedBy = "UNKNOWN";
        }
        throw new LockException("Could not acquire change log lock.  Currently locked by " + lockedBy);
    }
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.controller.UIRevertCommitController.java

private String createDefaultProjectName(ESLocalProject project) {
    final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    return project.getProjectName() + "@" + format.format(new Date()); //$NON-NLS-1$
}

From source file:de.uni_koeln.spinfo.maalr.webapp.controller.EditorController.java

@RequestMapping("/editor/export")
public void export(@RequestParam(value = "all", defaultValue = "true") boolean allVersions,
        @RequestParam(value = "dropKeys", defaultValue = "false") boolean dropKeys,
        HttpServletResponse response)/*w w w. j  a  va 2s .co m*/
        throws IOException, NoDatabaseAvailableException, JAXBException, NoSuchAlgorithmException {
    response.setContentType("application/zip");
    StringBuilder fileName = new StringBuilder();
    fileName.append("maalr_db_dump_");
    if (allVersions) {
        fileName.append("all_versions_");
    } else {
        fileName.append("current_versions_");
    }
    if (dropKeys) {
        fileName.append("anonymized_");
    }
    fileName.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date()));
    response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".zip");
    ServletOutputStream out = response.getOutputStream();
    service.exportData(allVersions, dropKeys, out, fileName.toString());
}

From source file:org.apache.hadoop.http.StaticServlet.java

public String getListHTML(Resource resource, String base, boolean parent) throws IOException {
    base = URIUtil.canonicalPath(base);/* ww  w  . j a  v a2s . c om*/
    if (base == null || !resource.isDirectory())
        return null;

    String[] ls = resource.list();
    if (ls == null)
        return null;
    Arrays.sort(ls);

    String decodedBase = URIUtil.decodePath(base);
    String title = "Directory: " + deTag(decodedBase);

    StringBuffer buf = new StringBuffer(4096);
    buf.append("<HTML><HEAD><TITLE>");
    buf.append(title);
    buf.append("</TITLE></HEAD><BODY>\n<H1>");
    buf.append(title);
    buf.append("</H1>\n<TABLE BORDER=0>\n");

    if (parent) {
        buf.append("<TR><TD><A HREF=\"");
        buf.append(URIUtil.addPaths(base, "../"));
        buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n");
    }

    String defangedBase = defangURI(base);

    DateFormat dfmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    for (int i = 0; i < ls.length; i++) {
        Resource item = resource.addPath(ls[i]);

        buf.append("\n<TR><TD><A HREF=\"");
        String path = URIUtil.addPaths(defangedBase, URIUtil.encodePath(ls[i]));
        buf.append(URIUtil.encodePath(ls[i]));

        if (item.isDirectory() && !path.endsWith("/"))
            buf.append(URIUtil.SLASH);

        // URIUtil.encodePath(buf,path);
        buf.append("\">");
        buf.append(deTag(ls[i]));
        buf.append("&nbsp;");
        buf.append("</TD><TD ALIGN=right>");
        buf.append(item.length());
        buf.append(" bytes&nbsp;</TD><TD>");
        buf.append(dfmt.format(new Date(item.lastModified())));
        buf.append("</TD></TR>");
    }
    buf.append("</TABLE>\n");
    buf.append("</BODY></HTML>\n");

    return buf.toString();
}

From source file:io.wcm.devops.conga.generator.FileGenerator.java

/**
 * Generate comment lines for file header added to all files for which a {@link FileHeaderPlugin} is registered.
 * @param dependencyVersions List of artifact versions to include
 * @return Formatted comment lines/* w  ww .j  a va 2  s . co  m*/
 */
private List<String> buildFileHeaderCommentLines(String version, List<String> dependencyVersions) {
    List<String> lines = new ArrayList<>();

    lines.add("This file is AUTO-GENERATED by CONGA. Please do no change it manually.");
    lines.add("");
    lines.add((version != null ? "Version " + version + ", generated " : "Generated ") + "at: "
            + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(new Date()));

    // add information how this file was generated
    lines.add("Environment: " + environmentName);
    lines.add("Role: " + roleName);
    if (StringUtils.isNotBlank(roleVariantName)) {
        lines.add("Variant: " + roleVariantName);
    }
    lines.add("Template: " + templateName);

    if (dependencyVersions != null && !dependencyVersions.isEmpty()) {
        lines.add("");
        lines.add("Dependencies:");
        lines.addAll(dependencyVersions);
    }

    return formatFileHeaderCommentLines(lines);
}

From source file:de.aw.awlib.preferences.AWPreferencesAllgemein.java

@CallSuper
@Override/*w  w w.  jav  a  2s  .  co m*/
public void onCreatePreferences(Bundle bundle, String s) {
    mApplication = ((AWApplication) getActivity().getApplicationContext());
    addPreferencesFromResource(R.xml.awlib_preferences_allgemein);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    for (int pkKey : mPrefs) {
        String key = getString(pkKey);
        Preference preference = findPreference(key);
        if (pkKey == R.string.pkCompileInfo) {
            java.util.Date date = new Date(BuildConfig.BuildTime);
            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
            StringBuilder buildInfo = new StringBuilder("Compilezeit: ").append(df.format(date));
            preference.setSummary(buildInfo);
        } else if (pkKey == R.string.pkVersionInfo) {
            StringBuilder versionInfo = new StringBuilder("Datenbankversion : ")
                    .append(mApplication.theDatenbankVersion()).append(", Version: ")
                    .append(BuildConfig.VERSION_NAME);
            preference.setSummary(versionInfo);
        } else if (pkKey == R.string.pkServerUID || pkKey == R.string.pkServerURL) {
            String value = prefs.getString(key, null);
            preference.setSummary(value);
        } else if (pkKey == R.string.pkSavePeriodic) {
            long value = prefs.getLong(DODATABASESAVE, Long.MAX_VALUE);
            setRegelmSicherungSummary(preference, prefs, value);
        }
        preference.setOnPreferenceClickListener(this);
    }
}