Example usage for java.text DateFormat getTimeInstance

List of usage examples for java.text DateFormat getTimeInstance

Introduction

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

Prototype

public static final DateFormat getTimeInstance(int style) 

Source Link

Document

Gets the time formatter with the given formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:net.nosleep.superanalyzer.analysis.views.TimeView.java

private void refreshDataset() {
    _dataset.clear();//w ww  .j  a v  a  2  s .c  o m

    Stat itemStats = null;

    if (_comboBox == null) {
        itemStats = _analysis.getStats(Analysis.KIND_TRACK, null);
    } else {
        ComboItem item = (ComboItem) _comboBox.getSelectedItem();
        itemStats = _analysis.getStats(item.getKind(), item.getValue());
    }

    int[] hours = itemStats.getHours();
    for (int i = 0; i < 24; i++) {

        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR_OF_DAY, i);
        c.set(Calendar.MINUTE, 0);

        SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT);

        _dataset.addValue(hours[i], Misc.getString("LISTENING_TIMES"), formatter.format(c.getTime()));
    }

    CategoryPlot plot = (CategoryPlot) _chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();

    axis.setAutoRangeStickyZero(false);

}

From source file:net.alexjf.tmm.fragments.ImmedTransactionEditorFragment.java

public ImmedTransactionEditorFragment() {
    dateFormat = DateFormat.getDateInstance();
    timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
}

From source file:com.autentia.intra.jsf.schedule.renderer.ActivityScheduleEntryRenderer.java

protected void renderCompactContent(FacesContext context, ResponseWriter writer, HtmlSchedule schedule,
        ScheduleDay day, ScheduleEntry entry, boolean selected) throws IOException {
    StringBuffer text = new StringBuffer();
    Date startTime = entry.getStartTime();

    if (day.getDayStart().after(entry.getStartTime())) {
        startTime = day.getDayStart();//from  w ww  .j  a  v a2 s. c o m
    }

    Date endTime = entry.getEndTime();

    if (day.getDayEnd().before(entry.getEndTime())) {
        endTime = day.getDayEnd();
    }

    if (!entry.isAllDay()) {
        DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
        text.append(format.format(startTime));
        if (!startTime.equals(endTime)) {
            text.append("-");
            text.append(format.format(endTime));
        }
        text.append(": ");
    }
    text.append(StringUtils.abbreviate(entry.getTitle(), 20));

    if (((ActivityScheduleEntry) entry).isBillable()) {
        writer.startElement(HTML.SPAN_ELEM, schedule);
        writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "entryBillable"), null);
    }

    writer.writeText(text.toString(), null);

    if (((ActivityScheduleEntry) entry).isBillable()) {
        writer.endElement(HTML.SPAN_ELEM);
    }

}

From source file:org.jactr.eclipse.runtime.launching.env.EnvironmentConfigurator.java

static public IFile createRuntimeEnvironmentFile(ILaunchConfiguration config, String mode,
        IProgressMonitor monitor) throws CoreException {
    /*//from   w w w. j ava2  s  .  c o m
     * make sure we have runs/
     */
    IFile configurationFile = null;
    IProject project = ACTRLaunchConfigurationUtils.getProject(config);

    if (config.getAttribute(ACTRLaunchConstants.ATTR_SAVE_RUN, true)) {
        IFolder runtimeFolder = project.getFolder("runs");

        if (!runtimeFolder.exists())
            runtimeFolder.create(true, true, monitor);

        /*
         * create {now}
         */
        Date now = new Date();
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
        String name = df.format(now);
        name = name.replace("/", ".");
        IFolder thisRun = runtimeFolder.getFolder(name);

        if (!thisRun.exists())
            thisRun.create(true, true, monitor);

        df = DateFormat.getTimeInstance(DateFormat.MEDIUM);
        name = df.format(now).replace(":", ".").replace(" ", "");
        thisRun = thisRun.getFolder(name);

        if (!thisRun.exists())
            thisRun.create(true, true, monitor);

        configurationFile = thisRun.getFile("environment.xml");
    } else {
        // tmp directory and temp file
        IPath workingLocation = project.getWorkingLocation(RuntimePlugin.PLUGIN_ID);
        workingLocation.append("/tmp/");
        IFolder tmpLocation = project.getFolder(workingLocation);
        tmpLocation.create(true, true, monitor);
        // TODO this could screw up if you try to run multiple instances at once
        configurationFile = tmpLocation.getFile(project.getName() + "-environment.xml");
    }

    return configurationFile;
}

From source file:com.autentia.tnt.jsf.schedule.renderer.ExternalActivityScheduleEntryRenderer.java

protected void renderCompactContent(FacesContext context, ResponseWriter writer, HtmlSchedule schedule,
        ScheduleDay day, ScheduleEntry entry, boolean selected) throws IOException {
    StringBuffer text = new StringBuffer();
    Date startTime = entry.getStartTime();

    if (day.getDayStart().after(entry.getStartTime())) {
        startTime = day.getDayStart();//from   w ww .  jav  a 2  s. c om
    }

    Date endTime = entry.getEndTime();

    if (day.getDayEnd().before(entry.getEndTime())) {
        endTime = day.getDayEnd();
    }

    if (!entry.isAllDay()) {
        DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
        text.append(format.format(startTime));
        if (!startTime.equals(endTime)) {
            text.append("-");
            text.append(format.format(endTime));
        }
        text.append(": ");
    }
    text.append(StringUtils.abbreviate(entry.getTitle(), 20));

    writer.startElement(HTML.SPAN_ELEM, schedule);
    writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "externalActivity"), null);

    writer.writeText(text.toString(), null);

    writer.endElement(HTML.SPAN_ELEM);

}

From source file:org.telscenter.sail.webapp.presentation.web.controllers.student.brainstorm.XMLBrainstorm.java

public static String getXMLComment(Comment comment) {
    Date timestamp = comment.getTimestamp();
    String formattedTime = DateFormat.getTimeInstance(DateFormat.SHORT).format(timestamp);

    String formattedDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(timestamp);

    String XMLComment = "<comment><id>" + comment.getId() + "</id><timestamp>" + formattedTime + " "
            + formattedDate + "</timestamp>" + getXMLWorkgroup(comment.getWorkgroup()) + "<body>"
            + StringEscapeUtils.escapeHtml(comment.getBody()) + "</body><anon>" + comment.isAnonymous()
            + "</anon></comment>";
    return XMLComment;
}

From source file:org.whisperim.android.ui.ChatWindow.java

private void appendMessage(Message m) {
    DateFormat d = DateFormat.getTimeInstance(DateFormat.MEDIUM);
    messageHistory_.setText(messageHistory_.getText() + m.getFromBuddy().getAlias() + " ("
            + d.format(m.getTimeSent()) + "): " + m.getMessage() + "\n");
}

From source file:org.hawkular.client.android.fragment.MetricFragment.java

private void setUpMetricData(List<MetricData> metricDataList) {
    this.metricData = new ArrayList<>(metricDataList);

    sortMetricData(metricDataList);/*from   w  ww  . j a v a 2s .  c  o m*/

    List<PointValue> chartPoints = new ArrayList<>();

    List<AxisValue> chartAxisPoints = new ArrayList<>();

    for (int metricDataPosition = 0; metricDataPosition < metricDataList.size(); metricDataPosition++) {
        MetricData metricData = metricDataList.get(metricDataPosition);

        chartPoints.add(new PointValue(metricDataPosition, metricData.getValue()));

        chartAxisPoints.add(new AxisValue(metricDataPosition).setLabel(
                DateFormat.getTimeInstance(DateFormat.SHORT).format(new Date(metricData.getTimestamp()))));
    }

    Line chartLine = new Line(chartPoints).setColor(getResources().getColor(R.color.background_primary_dark))
            .setCubic(true).setHasPoints(false);

    LineChartData chartData = new LineChartData().setLines(Collections.singletonList(chartLine));
    chartData.setAxisXBottom(new Axis().setValues(chartAxisPoints));
    chartData.setAxisYLeft(new Axis().setHasLines(true));

    chart.setLineChartData(chartData);

    Viewport chartViewport = new Viewport(chart.getMaximumViewport());

    chartViewport.bottom = chart.getMaximumViewport().bottom - 50;
    chartViewport.top = chart.getMaximumViewport().top + 50;

    chart.setMaximumViewport(chartViewport);
    chart.setCurrentViewport(chartViewport);

    hideRefreshing();

    showChart();
}

From source file:op.care.prescription.PnlScheduleDose.java

private void cmbUhrzeitItemStateChanged(ItemEvent e) {
    //        currentSelectedTime = (Date) e.getItem();
    lblTimeDose.setText(SYSTools.xx(internalClassID + ".lblTimeDose") + " "
            + DateFormat.getTimeInstance(DateFormat.SHORT).format(e.getItem()) + " "
            + SYSTools.xx("misc.msg.Time.short"));
}

From source file:net.nosleep.superanalyzer.analysis.views.SummaryView.java

public static Vector createStatPairs(Analysis analysis) {

    Stat trackStats = analysis.getStats(Analysis.KIND_TRACK, null);

    String name;//www  . j a  v a2s .  c  o  m
    String value;
    String description;
    StringTriple triple;

    Vector statPairs = new Vector();

    name = Misc.getString("TRACK_COUNT");
    value = Misc.getFormattedCountAsInt(trackStats.getTrackCount(), Misc.getString("TRACK"),
            Misc.getString("TRACKS"));
    description = Misc.getString("TRACK_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("PLAY_COUNT");
    value = Misc.getFormattedCountAsInt(trackStats.getPlayCount(), Misc.getString("TRACK"),
            Misc.getString("TRACKS")) + " " + Misc.getString("PLAYED");
    description = Misc.getString("PLAY_COUNT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("TOTAL_TIME");
    value = Misc.getFormattedDuration(trackStats.getTotalTime());
    description = Misc.getString("TOTAL_TIME_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("TOTAL_PLAY_TIME");
    value = Misc.getFormattedDuration(trackStats.getTotalPlayTime());
    description = Misc.getString("TOTAL_PLAY_TIME_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("ARTIST_COUNT");
    value = Misc.getFormattedCountAsInt(analysis.getHash(Analysis.KIND_ARTIST).size(), Misc.getString("ARTIST"),
            Misc.getString("ARTISTS"));
    description = Misc.getString("ARTIST_COUNT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("ALBUM_COUNT");
    value = Misc.getFormattedCountAsInt(analysis.getHash(Analysis.KIND_ALBUM).size(), Misc.getString("ALBUM"),
            Misc.getString("ALBUMS"));
    description = Misc.getString("ALBUM_COUNT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("GENRE_COUNT");
    value = Misc.getFormattedCountAsInt(analysis.getHash(Analysis.KIND_GENRE).size(), Misc.getString("GENRE"),
            Misc.getString("GENRES"));
    description = Misc.getString("GENRE_COUNT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("MOST_SONGS_PLAYED_AT");
    int hour = trackStats.getPopularHour();
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, hour);
    c.set(Calendar.MINUTE, 0);
    SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT);
    value = formatter.format(c.getTime()) + " " + Misc.getString("HOUR_SUFFIX");
    description = Misc.getString("MOST_SONGS_PLAYED_AT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_TRACK_LENGTH");
    value = Misc.getFormattedDuration(trackStats.getAvgLength());
    description = Misc.getString("AVERAGE_TRACK_LENGTH_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_PLAY_COUNT");
    value = Misc.getFormattedCount(trackStats.getAvgPlayCount(), Misc.getString("PLAY"),
            Misc.getString("PLAYS")) + " " + Misc.getString("PER_SONG");
    description = Misc.getString("AVERAGE_PLAY_COUNT_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_ALBUM_COMPLETENESS");
    value = Misc.getFormattedPercentage(analysis.getAvgAlbumCompleteness()) + " " + Misc.getString("COMPLETE");
    description = Misc.getString("AVERAGE_ALBUM_COMPLETENESS_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("COMPLETE_ALBUMS");
    value = Misc.getFormattedPercentage(analysis.getAvgCompleteAlbums()) + " " + Misc.getString("ARE_COMPLETE");
    description = Misc.getString("COMPLETE_ALBUMS_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_BIT_RATE");
    value = Misc.getFormattedBitrate(analysis.getAvgBitRate());
    description = Misc.getString("AVERAGE_BIT_RATE_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_FILE_SIZE");
    value = Misc.getFormattedByteCount(analysis.getAvgFileSize());
    description = Misc.getString("AVERAGE_FILE_SIZE_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("TOTAL_LIBRARY_SIZE");
    value = Misc.getFormattedByteCount(analysis.getTotalLibrarySize());
    description = Misc.getString("TOTAL_LIBRARY_SIZE_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("ALL_SONGS_PLAYED");
    value = Misc.getFormattedPercentage(analysis.getAvgTracksPlayedAtLeastOnce()) + " "
            + Misc.getString("PLAYED_AT_LEAST_ONCE");
    description = Misc.getString("ALL_SONGS_PLAYED_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("COMPILATIONS");
    value = Misc.getFormattedPercentage(trackStats.getTrackCompilationPercentage());
    description = Misc.getString("COMPILATIONS_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("LIBRARY_AGE");
    value = Misc.getFormattedDuration(analysis.getLibraryAge());
    description = Misc.getString("LIBRARY_AGE_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    name = Misc.getString("AVERAGE_GROWTH_RATE");
    value = Misc.getFormattedCount(analysis.getAverageGrowthRate(), Misc.getString("SONG"),
            Misc.getString("SONGS")) + "/" + Misc.capitalizeByLocale(Misc.getString("WEEK"));
    description = Misc.getString("AVERAGE_GROWTH_RATE_TOOLTIP");
    triple = new StringTriple(name, value, description);
    statPairs.add(triple);

    return statPairs;
}