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.grails.gsp.GroovyPageWritable.java

protected Writer doWriteTo(OutputContext outputContext, Writer out) throws IOException {
    if (shouldShowGroovySource(outputContext)) {
        // Set it to TEXT
        outputContext.setContentType(GROOVY_SOURCE_CONTENT_TYPE); // must come before response.getOutputStream()
        writeGroovySourceToResponse(metaInfo, out);
    } else {/*from  w w w. j  a  va2s .c  o m*/
        boolean debugTemplates = shouldDebugTemplates(outputContext);

        // Set it to HTML by default
        if (metaInfo.getCompilationException() != null) {
            throw metaInfo.getCompilationException();
        }

        // Set up the script context
        AbstractTemplateVariableBinding parentBinding = null;
        boolean hasRequest = outputContext != null;
        boolean newParentCreated = false;

        if (hasRequest) {
            parentBinding = outputContext.getBinding();
            if (parentBinding == null) {
                parentBinding = outputContext.createAndRegisterRootBinding();
                newParentCreated = true;
            }
        }

        if (allowSettingContentType && hasRequest) {
            // only try to set content type when evaluating top level GSP
            boolean contentTypeAlreadySet = outputContext.isContentTypeAlreadySet();
            if (!contentTypeAlreadySet) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Writing output with content type: " + metaInfo.getContentType());
                }
                outputContext.setContentType(metaInfo.getContentType()); // must come before response.getWriter()
            }
        }

        GroovyPageBinding binding = createBinding(parentBinding);
        if (hasRequest) {
            outputContext.setBinding(binding);
        }

        GroovyPage page = null;
        try {
            page = (GroovyPage) metaInfo.getPageClass().newInstance();
        } catch (Exception e) {
            throw new GroovyPagesException("Problem instantiating page class", e);
        }
        page.setBinding(binding);
        binding.setOwner(page);

        page.initRun(out, outputContext, metaInfo);

        int debugId = 0;
        long debugStartTimeMs = 0;
        if (debugTemplates) {
            debugId = incrementAndGetDebugTemplatesIdCounter(outputContext);
            out.write("<!-- GSP #");
            out.write(String.valueOf(debugId));
            out.write(" START template: ");
            out.write(page.getGroovyPageFileName());
            out.write(" precompiled: ");
            out.write(String.valueOf(metaInfo.isPrecompiledMode()));
            out.write(" lastmodified: ");
            out.write(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                    .format(new Date(metaInfo.getLastModified())));
            out.write(" -->");
            debugStartTimeMs = System.currentTimeMillis();
        }
        try {
            page.run();
        } finally {
            page.cleanup();
            if (hasRequest) {
                if (newParentCreated) {
                    outputContext.setBinding(null);
                } else {
                    outputContext.setBinding(parentBinding);
                }
            }
        }
        if (debugTemplates) {
            out.write("<!-- GSP #");
            out.write(String.valueOf(debugId));
            out.write(" END template: ");
            out.write(page.getGroovyPageFileName());
            out.write(" rendering time: ");
            out.write(String.valueOf(System.currentTimeMillis() - debugStartTimeMs));
            out.write(" ms -->");
        }
    }
    return out;
}

From source file:com.mobicage.rogerthat.FriendsLocationActivity.java

private void displayLocations() {
    T.UI();//  w  w w  . j a va  2 s. c o  m
    mLoadingProgressbar.setVisibility(View.GONE);
    mLoadingLayout.setVisibility(View.GONE);
    mFriendMap.setVisibility(View.VISIBLE);
    // Calculate bounds
    double maxLat = Double.MIN_VALUE;
    double minLat = Double.MAX_VALUE;
    double maxLon = Double.MIN_VALUE;
    double minLon = Double.MAX_VALUE;
    for (LocationResultRequestTO fl : mLocations) {
        if (fl.location.latitude > maxLat)
            maxLat = fl.location.latitude;
        if (fl.location.latitude < minLat)
            minLat = fl.location.latitude;
        if (fl.location.longitude > maxLon)
            maxLon = fl.location.longitude;
        if (fl.location.longitude < minLon)
            minLon = fl.location.longitude;
    }
    mFriendMap.getController().zoomToSpan((int) ((maxLat - minLat)), (int) ((maxLon - minLon)));
    GeoPoint center = new GeoPoint((int) ((maxLat + minLat) / 2), (int) ((maxLon + minLon) / 2));
    mFriendMap.getController().setCenter(center);
    for (LocationResultRequestTO fl : mLocations) {
        if (mAdded.contains(fl.friend))
            continue;
        mAdded.add(fl.friend);

        if (fl.friend.equals(mMyIdentity.getEmail())) {
            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(mMyIdentity), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, mMyIdentity.getName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        } else {
            Friend friend = mFriendsPlugin.getStore().getExistingFriend(fl.friend);

            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(friend), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, friend.getDisplayName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        }
    }
    if (mAdded.size() == 1 && mAdded.get(0).equals(mMyIdentity.getEmail()))
        UIUtils.showLongToast(this,
                getString(R.string.your_location_displayed_friend_have_contacted_for_their_location));
}

From source file:HardcopyWriter.java

/**
 * The constructor for this class has a bunch of arguments: The frame argument
 * is required for all printing in Java. The jobname appears left justified at
 * the top of each printed page. The font size is specified in points, as
 * on-screen font sizes are. The margins are specified in inches (or fractions
 * of inches).//from ww w. j  av a 2 s  . c o m
 */
public HardcopyWriter(Frame frame, String jobname, int fontsize, double leftmargin, double rightmargin,
        double topmargin, double bottommargin) throws HardcopyWriter.PrintCanceledException {
    // Get the PrintJob object with which we'll do all the printing.
    // The call is synchronized on the static printprops object, which
    // means that only one print dialog can be popped up at a time.
    // If the user clicks Cancel in the print dialog, throw an exception.
    Toolkit toolkit = frame.getToolkit(); // get Toolkit from Frame
    synchronized (printprops) {
        job = toolkit.getPrintJob(frame, jobname, printprops);
    }
    if (job == null)
        throw new PrintCanceledException("User cancelled print request");

    pagesize = job.getPageDimension(); // query the page size
    pagedpi = job.getPageResolution(); // query the page resolution

    // Bug Workaround:
    // On windows, getPageDimension() and getPageResolution don't work, so
    // we've got to fake them.
    if (System.getProperty("os.name").regionMatches(true, 0, "windows", 0, 7)) {
        // Use screen dpi, which is what the PrintJob tries to emulate
        pagedpi = toolkit.getScreenResolution();
        // Assume a 8.5" x 11" page size. A4 paper users must change this.
        pagesize = new Dimension((int) (8.5 * pagedpi), 11 * pagedpi);
        // We also have to adjust the fontsize. It is specified in points,
        // (1 point = 1/72 of an inch) but Windows measures it in pixels.
        fontsize = fontsize * pagedpi / 72;
    }

    // Compute coordinates of the upper-left corner of the page.
    // I.e. the coordinates of (leftmargin, topmargin). Also compute
    // the width and height inside of the margins.
    x0 = (int) (leftmargin * pagedpi);
    y0 = (int) (topmargin * pagedpi);
    width = pagesize.width - (int) ((leftmargin + rightmargin) * pagedpi);
    height = pagesize.height - (int) ((topmargin + bottommargin) * pagedpi);

    // Get body font and font size
    font = new Font("Monospaced", Font.PLAIN, fontsize);
    metrics = frame.getFontMetrics(font);
    lineheight = metrics.getHeight();
    lineascent = metrics.getAscent();
    charwidth = metrics.charWidth('0'); // Assumes a monospaced font!

    // Now compute columns and lines will fit inside the margins
    chars_per_line = width / charwidth;
    lines_per_page = height / lineheight;

    // Get header font information
    // And compute baseline of page header: 1/8" above the top margin
    headerfont = new Font("SansSerif", Font.ITALIC, fontsize);
    headermetrics = frame.getFontMetrics(headerfont);
    headery = y0 - (int) (0.125 * pagedpi) - headermetrics.getHeight() + headermetrics.getAscent();

    // Compute the date/time string to display in the page header
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);
    df.setTimeZone(TimeZone.getDefault());
    time = df.format(new Date());

    this.jobname = jobname; // save name
    this.fontsize = fontsize; // save font size
}

From source file:com.greenpepper.confluence.velocity.ConfluenceGreenPepper.java

public String getVersionDate() {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    return df.format(GreenPepperServer.versionDate());
}

From source file:org.opencms.scheduler.jobs.CmsPublishScheduledJob.java

/**
 * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map)
 *///from w w  w .  java2 s .c  o m
@SuppressWarnings("unchecked")
public synchronized String launch(CmsObject cms, Map parameters) throws Exception {

    Date jobStart = new Date();
    String finishMessage;
    String linkcheck = (String) parameters.get(PARAM_LINKCHECK);
    String jobName = (String) parameters.get(PARAM_JOBNAME);
    CmsProject project = cms.getRequestContext().getCurrentProject();
    CmsLogReport report = new CmsLogReport(cms.getRequestContext().getLocale(), CmsPublishScheduledJob.class);

    try {

        // validate links if linkcheck parameter was given
        if (Boolean.valueOf(linkcheck).booleanValue()) {
            OpenCms.getPublishManager().validateRelations(cms, OpenCms.getPublishManager().getPublishList(cms),
                    report);
        }

        // change lock for the resources if necessary
        Iterator<String> iter = cms.readProjectResources(project).iterator();
        while (iter.hasNext()) {
            String resource = iter.next();
            // get current lock from file
            CmsLock lock = cms.getLock(resource);
            // prove is current lock from current but not in current project
            if ((lock != null) && lock.isInProject(cms.getRequestContext().getCurrentProject())
                    && !lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) {
                // file is locked in current project but not by current user
                // unlock this file
                cms.changeLock(resource);
            }
        }

        // publish the project, the publish output will be put in the logfile
        OpenCms.getPublishManager().publishProject(cms, report);
        OpenCms.getPublishManager().waitWhileRunning();
        finishMessage = Messages.get().getBundle().key(Messages.LOG_PUBLISH_FINISHED_1, project.getName());
    } catch (CmsException e) {
        // there was an error, so create an output for the logfile
        finishMessage = Messages.get().getBundle().key(Messages.LOG_PUBLISH_FAILED_2, project.getName(),
                e.getMessageContainer().key());

        // add error to report
        report.addError(finishMessage);
    } finally {
        //wait for other processes that may add entries to the report
        long lastTime = report.getLastEntryTime();
        long beforeLastTime = 0;
        while (lastTime != beforeLastTime) {
            wait(30000);
            beforeLastTime = lastTime;
            lastTime = report.getLastEntryTime();
        }

        // delete the job
        // the job id
        String jobId = "";
        // iterate over all jobs to find the current one
        Iterator<CmsScheduledJobInfo> iter = OpenCms.getScheduleManager().getJobs().iterator();
        while (iter.hasNext()) {
            CmsScheduledJobInfo jobInfo = iter.next();
            // the current job is found with the job name
            if (jobInfo.getJobName().equals(jobName)) {
                // get the current job id
                jobId = jobInfo.getId();
            }
        }
        // delete the current job
        OpenCms.getScheduleManager().unscheduleJob(cms, jobId);

        // send publish notification
        if (report.hasWarning() || report.hasError()) {
            try {
                String userName = (String) parameters.get(PARAM_USER);
                CmsUser user = cms.readUser(userName);

                CmsPublishNotification notification = new CmsPublishNotification(cms, user, report);

                DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
                notification.addMacro("jobStart", df.format(jobStart));

                notification.send();
            } catch (Exception e) {
                LOG.error(Messages.get().getBundle().key(Messages.LOG_PUBLISH_SEND_NOTIFICATION_FAILED_0), e);
            }
        }
    }

    return finishMessage;
}

From source file:DateTimeEditor.java

protected void setupFormat() {
    switch (m_timeOrDateType) {
    case TIME://from  w ww. java  2s  . c om
        m_format = DateFormat.getTimeInstance(m_lengthStyle);
        break;
    case DATE:
        m_format = DateFormat.getDateInstance(m_lengthStyle);
        break;
    case DATETIME:
        m_format = DateFormat.getDateTimeInstance(m_lengthStyle, m_lengthStyle);
        break;
    }
}

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

/**
 * Verifies that the table on the {@link CauseManagement} page displays all causes with description and that
 * one of them can be navigated to and a valid edit page for that cause is shown.
 *
 * @throws Exception if so.//from w  w w.  ja v a2  s. c  o  m
 */
public void testTableViewNavigation() throws Exception {
    KnowledgeBase kb = PluginImpl.getInstance().getKnowledgeBase();

    //Overriding isStatisticsEnabled in order to display all fields on the management page:
    KnowledgeBase mockKb = spy(kb);
    when(mockKb.isStatisticsEnabled()).thenReturn(true);
    Whitebox.setInternalState(PluginImpl.getInstance(), "knowledgeBase", mockKb);

    List<String> myCategories = new LinkedList<String>();
    myCategories.add("myCtegory");

    //CS IGNORE MagicNumber FOR NEXT 5 LINES. REASON: TestData.
    Date endOfWorld = new Date(1356106375000L);
    Date birthday = new Date(678381175000L);
    Date millenniumBug = new Date(946681200000L);
    Date pluginReleased = new Date(1351724400000L);

    FailureCause cause = new FailureCause(null, "SomeName", "A Description", "Some comment", endOfWorld,
            myCategories, null, Collections.singletonList(new FailureCauseModification("user", birthday)));
    cause.addIndication(new BuildLogIndication("."));
    kb.addCause(cause);
    cause = new FailureCause(null, "SomeOtherName", "A Description", "Another comment", millenniumBug,
            myCategories, null,
            Collections.singletonList(new FailureCauseModification("user", pluginReleased)));
    cause.addIndication(new BuildLogIndication("."));
    kb.addCause(cause);

    WebClient web = createWebClient();
    HtmlPage page = web.goTo(CauseManagement.URL_NAME);
    HtmlTable table = (HtmlTable) page.getElementById("failureCausesTable");

    Collection<FailureCause> expectedCauses = kb.getShallowCauses();

    int rowCount = table.getRowCount();
    assertEquals(expectedCauses.size() + 1, rowCount);
    Iterator<FailureCause> causeIterator = expectedCauses.iterator();

    FailureCause firstCause = null;

    for (int i = 1; i < rowCount; i++) {
        assertTrue(causeIterator.hasNext());
        FailureCause c = causeIterator.next();
        HtmlTableRow row = table.getRow(i);
        String name = row.getCell(NAME_CELL).getTextContent();
        String categories = row.getCell(CATEGORY_CELL).getTextContent();
        String description = row.getCell(DESCRIPTION_CELL).getTextContent();
        String comment = row.getCell(COMMENT_CELL).getTextContent();
        String modified = row.getCell(MODIFIED_CELL).getTextContent();
        String lastSeen = row.getCell(LAST_SEEN_CELL).getTextContent();
        assertEquals(c.getName(), name);
        assertEquals(c.getCategoriesAsString(), categories);
        assertEquals(c.getDescription(), description);
        assertEquals(c.getComment(), comment);
        assertEquals("Modified date should be visible",
                DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                        .format(c.getLatestModification().getTime()) + " by user",
                modified);
        assertEquals("Last seen date should be visible",
                DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(c.getLastOccurred()),
                lastSeen);
        if (i == 1) {
            firstCause = c;
        }
    }

    //The table looks ok, now lets see if we can navigate correctly.

    assertNotNull(firstCause);

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

    verifyCorrectCauseEditPage(firstCause, editPage);
}

From source file:org.hyperic.hq.livedata.formatters.TopFormatter.java

private String formatHtml(ConfigResponse cfg, TopData t) {
    StringBuffer r = new StringBuffer();
    DateFormat dateFmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
    UptimeData utd = t.getUptime();//www  . j av a 2s  .co m

    r.append("<div class='top_livedata'><div class='fivepad' style='background:#efefef;'><b>Time</b>: ")
            .append(h(dateFmt.format(new Date(utd.getTime())))).append(" up ")
            .append(h(utd.getFormattedUptime())).append("<br/>");

    r.append("<b>Load Avg</b>: ").append(h(utd.getFormattedLoadavg())).append("<br/>");

    CpuPerc cpu = t.getCpu();
    r.append("<b>CPU States</b>: ")
            .append(h(BUNDLE.format("formatter.top.cpuStates", CpuPerc.format(cpu.getUser()),
                    CpuPerc.format(cpu.getSys()), CpuPerc.format(cpu.getNice()), CpuPerc.format(cpu.getWait()),
                    CpuPerc.format(cpu.getIdle()))))
            .append("<br/>");

    Mem mem = t.getMem();
    r.append("<b>Mem</b>: ").append(h(BUNDLE.format("formatter.top.memUse", (mem.getTotal() / 1024) + "k",
            (mem.getUsed() / 1024) + "k", (mem.getFree() / 1024) + "k"))).append("<br/>");

    Swap swap = t.getSwap();
    r.append("<b>Swap</b>: ").append(h(BUNDLE.format("formatter.top.memUse", (swap.getTotal() / 1024) + "k",
            (swap.getUsed() / 1024) + "k", (swap.getFree() / 1024) + "k"))).append("<br/>");

    ProcStat ps = t.getProcStat();
    r.append("<b>Processes</b>: ").append(h(BUNDLE.format("formatter.top.procSummary", "" + ps.getTotal(),
            "" + ps.getRunning(), "" + ps.getSleeping(), "" + ps.getStopped(), "" + ps.getZombie())))
            .append("<br/><br/>");

    r.append("</div><table cellpadding='0' cellspacing='0' width='100%'><thead><tr><td>")
            .append(BUNDLE.format("formatter.top.proc.pid")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.user")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.stime")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.size")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.rss")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.share")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.state")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.time")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.cpu")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.mem")).append("</td><td>")
            .append(BUNDLE.format("formatter.top.proc.name")).append("</td></tr></thead><tbody>");

    for (Object element : t.getProcesses()) {
        ProcessData d = (ProcessData) element;
        char[] buf = new char[1];
        buf[0] = d.getState();
        String str = new String(buf);
        char stateStr = ((str.trim().length() == 0) ? '-' : d.getState());
        r.append("<tr><td>").append(d.getPid()).append("</td>").append("<td>").append(d.getOwner())
                .append("</td>").append("<td>").append(d.getFormattedStartTime()).append("</td>").append("<td>")
                .append(d.getFormattedSize()).append("</td>").append("<td>").append(d.getFormattedResident())
                .append("</td>").append("<td>").append(d.getFormattedShare()).append("</td>").append("<td>")
                .append(stateStr).append("</td>").append("<td>").append(d.getFormattedCpuTotal())
                .append("</td>").append("<td>").append(d.getFormattedCpuPerc()).append("</td>").append("<td>")
                .append(d.getFormattedMemPerc()).append("</td>").append("<td>").append(h(d.getBaseName()))
                .append("</td></tr>");
    }

    r.append("</tbody></table></div>");
    return r.toString();
}

From source file:org.kalypso.model.wspm.tuhh.core.wspwin.WspWinExporter.java

private static void write1DTuhhSteuerparameter(final TuhhCalculation calculation, final File batFile,
        final File zustFile, final File qwtFile, final File psiFile, final TuhhStationRange stationRange)
        throws IOException {
    final MODE calcMode = calculation.getCalcMode();

    Formatter pw = null;/*from  w w  w .j  a va  2 s .  c  o m*/
    try {
        batFile.getParentFile().mkdirs();

        pw = new Formatter(batFile);

        pw.format("# %s%n", calculation.getName()); //$NON-NLS-1$
        pw.format("# %s%n", //$NON-NLS-1$
                DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date()));

        pw.format("%n"); //$NON-NLS-1$
        pw.format("PROJEKTPFAD=%s%n", "."); //$NON-NLS-1$ //$NON-NLS-2$
        pw.format("STRANGDATEI=%s%n", zustFile.getName()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte:%n"); //$NON-NLS-1$
        pw.format("# WATERLEVEL%n"); //$NON-NLS-1$
        pw.format("# BF_UNIFORM%n"); //$NON-NLS-1$
        pw.format("# BF_NON_UNIFORM%n"); //$NON-NLS-1$
        pw.format("# REIB_KONST%n"); //$NON-NLS-1$

        pw.format("BERECHNUNGSMODUS=%s%n", calcMode.name()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte:%n"); //$NON-NLS-1$
        pw.format("# DARCY_WEISBACH_OHNE_FORMEINFLUSS%n"); //$NON-NLS-1$
        pw.format("# DARCY_WEISBACH_MIT_FORMEINFLUSS%n"); //$NON-NLS-1$
        pw.format("# MANNING_STRICKLER%n"); //$NON-NLS-1$
        pw.format("FLIESSGESETZ=%s%n", calculation.getFliessgesetz().name()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$

        pw.format(Locale.US, "ANFANGSSTATION=%s%n", stationRange.getExportFrom()); //$NON-NLS-1$
        pw.format(Locale.US, "ENDSTATION=%s%n", stationRange.getExportTo()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte%n"); //$NON-NLS-1$
        pw.format("# CRITICAL_WATER_DEPTH%n"); //$NON-NLS-1$
        pw.format("# UNIFORM_BOTTOM_SLOPE%n"); //$NON-NLS-1$
        pw.format("# WATERLEVEL%n"); //$NON-NLS-1$
        pw.format("ART_RANDBEDINGUNG=%s%n", calculation.getStartKind().name()); //$NON-NLS-1$
        final Double startWaterlevel = calculation.getStartWaterlevel();
        if (startWaterlevel != null) {
            pw.format(Locale.US, "ANFANGSWASSERSPIEGEL=%s%n", startWaterlevel); //$NON-NLS-1$
        }
        final BigDecimal startSlope = calculation.getStartSlope();
        if (startSlope != null) {
            pw.format("GEFAELLE=%s%n", startSlope); //$NON-NLS-1$
        }

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte%n"); //$NON-NLS-1$
        pw.format("# NON%n"); //$NON-NLS-1$
        pw.format("# DVWK%n"); //$NON-NLS-1$
        pw.format("# BJOERNSEN%n"); //$NON-NLS-1$
        pw.format("# DFG%n"); //$NON-NLS-1$
        pw.format("VERZOEGERUNGSVERLUST=%s%n", calculation.getVerzoegerungsverlust().name()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte%n"); //$NON-NLS-1$
        pw.format("# SIMPLE%n"); //$NON-NLS-1$
        pw.format("# EXACT%n"); //$NON-NLS-1$
        pw.format("ITERATIONSART=%s%n", calculation.getIterationType().name()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte%n"); //$NON-NLS-1$
        pw.format("# TRAPEZ_FORMULA%n"); //$NON-NLS-1$
        pw.format("# GEOMETRIC_FORMULA%n"); //$NON-NLS-1$
        pw.format("REIBUNGSVERLUST=%s%n", calculation.getReibungsverlust().name()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("# mgliche Werte: true / false%n"); //$NON-NLS-1$
        pw.format("MIT_BRUECKEN=%b%n", calculation.isCalcBridges()); //$NON-NLS-1$
        pw.format("MIT_WEHREN=%b%n", calculation.isCalcBarrages()); //$NON-NLS-1$
        pw.format("USE_EXTREM_ROUGH=%b%n", calculation.isUseExtremeRoughness()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("ABFLUSSEREIGNIS=%s%n", qwtFile.getName()); //$NON-NLS-1$

        pw.format("%n"); //$NON-NLS-1$
        pw.format("EINZELVERLUSTE=%s%n", psiFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$

        pw.format("%n"); //$NON-NLS-1$
        final Double minQ = calculation.getMinQ();
        if (minQ != null) {
            pw.format(Locale.US, "MIN_Q=%s%n", minQ); //$NON-NLS-1$
        }
        final Double maxQ = calculation.getMaxQ();
        if (maxQ != null) {
            pw.format(Locale.US, "MAX_Q=%s%n", maxQ); //$NON-NLS-1$
        }
        final Double qstep = calculation.getQStep();
        if (qstep != null) {
            pw.format(Locale.US, "DELTA_Q=%s%n", qstep); //$NON-NLS-1$
        }

        pw.format("%n"); //$NON-NLS-1$
        // Einheit des Durchflusses wird standardmig festgelegt
        pw.format("# mgliche Werte%n"); //$NON-NLS-1$
        pw.format("# QM_S%n"); //$NON-NLS-1$
        pw.format("# L_S%n"); //$NON-NLS-1$
        pw.format("DURCHFLUSS_EINHEIT=QM_S%n"); //$NON-NLS-1$

        FormatterUtils.checkIoException(pw);
    } finally {
        if (pw != null) {
            pw.close();
        }
    }

}

From source file:org.rhq.modules.plugins.wildfly10.util.PatchDetails.java

@Override
public String toString() {
    DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);

    return "{\n  \"patch-id\": \"" + id + "\",\n  \"type\": \"" + type + "\",\n  \"applied-at\": \""
            + format.format(appliedAt) + "\"\n}";
}