Example usage for java.text DateFormat format

List of usage examples for java.text DateFormat format

Introduction

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

Prototype

public final String format(Date date) 

Source Link

Document

Formats a Date into a date-time string.

Usage

From source file:com.ibm.bi.dml.api.DMLScript.java

/**
 * /*from w  w w. j  ava 2  s.c o m*/
 * @return
 */
private static String getDateTime() {
    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    Date date = new Date();
    return dateFormat.format(date);
}

From source file:it.geosolutions.mariss.wps.gs.DownloadProcess.java

public static String buildCQLFilterMinMaxIntervalAndGranulesBBox(/*List<String> timeList, */String minTime,
        String maxTime, File mosaicDir, List<String> granulesFileNames) {

    /*//w w  w.j  a v  a  2s .co  m
     * EXAMPLE:
     * time DURING 2010-01-24T09:52:32Z/2012-02-24T22:11:33Z AND (BBOX(wkb_geometry,9.887190592840616,37.981477602075785,10.310190592840616,38.38117760207579) OR BBOX(wkb_geometry,18.716863606878906,39.50822439921374,19.130563606878905,39.899624399213735))
     */

    GranulesManager gm = new GranulesManager(mosaicDir);
    Map<String, BoundingBox> bboxMap = gm.searchBoundingBoxes(granulesFileNames);

    //        TimeParser p = new TimeParser();
    //        Date min = null;
    //        Date max = null;
    //        boolean firstIter = true;
    //        for(String el : timeList){
    //            try {
    //                Date tmpDate = p.parse(el).get(0);
    //                if(firstIter){
    //                    min = tmpDate;
    //                    max = tmpDate;
    //                    firstIter=false;
    //                }
    //                else{
    //                    min = (tmpDate.before(min))?tmpDate:min;
    //                    max = (tmpDate.after(max))?tmpDate:max;
    //                }
    //            } catch (ParseException e) {
    //                LOGGER.severe(e.getMessage());
    //            }
    //        }
    //        if(min.equals(max)){
    //            Calendar cla = new GregorianCalendar();
    //            cla.setTime(min);
    //            cla.add(Calendar.DAY_OF_MONTH, -1);
    //            min = cla.getTime();
    //        }
    TimeParser p = new TimeParser();
    StringBuilder sb = new StringBuilder();
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Date min = null;
    Date max = null;
    try {
        min = p.parse(minTime).get(0);
        max = p.parse(maxTime).get(0);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        LOGGER.severe(e.getMessage());
    }
    sb.append("&CQL_FILTER=");
    if (min != null && max != null) {
        sb.append("time%20DURING%20");
        sb.append(formatter.format(min));
        sb.append("/");
        sb.append(formatter.format(max));
        LOGGER.info("Time Interval added to CQL filter");
        if (!bboxMap.isEmpty()) {
            sb.append("%20AND%20(");
            sb.append(concatCqlBBOXFilters(bboxMap));
            sb.append(")");
        }

    } else {
        sb.append("");
        LOGGER.info("The CQL filter is empty...");
    }
    String cqlFilter = sb.toString();
    LOGGER.fine("The full CQL filter is " + cqlFilter);
    return cqlFilter;
}

From source file:com.aurel.track.exchange.msProject.exchange.MsProjectExchangeBL.java

/**
 * Parse the date according to dateFormat
 *//*from www .  ja va2s .  c  o  m*/
public static String formatDate(Date date) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    if (date != null) {
        try {
            return dateFormat.format(date);
        } catch (Exception e) {
            LOGGER.debug(e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return "";
}

From source file:eionet.util.VocabularyCSVOutputHelper.java

/**
 * Writes CSV to output stream.//from   w w  w  .ja v  a 2  s .  c o m
 *
 * @param out
 *            outputstream
 * @param uriPrefix
 *            uri prefix for teh element identifiers
 * @param folderContextRoot
 *            parent vocabulary folder root for related identifiers
 * @param concepts
 *            list of vocabulary concepts
 * @param attributesMeta
 *            list of field names to the CSV header row
 * @throws IOException
 *             if error in I/O
 */
public static void writeCSV(OutputStream out, String uriPrefix, String folderContextRoot,
        List<VocabularyConcept> concepts, List<Triple<String, String, Integer>> attributesMeta)
        throws IOException {

    OutputStreamWriter osw = new OutputStreamWriter(out, "UTF-8");
    addBOM(out);

    List<String> toBeAddedToHeader = new ArrayList<String>();
    for (Triple<String, String, Integer> row : attributesMeta) {
        String lang = "";
        if (StringUtils.isNotEmpty(row.getCentral())) {
            lang = "@" + row.getCentral();
        }
        int numOfElements = row.getRight();
        for (int i = 0; i < numOfElements; i++) {
            toBeAddedToHeader.add(row.getLeft() + lang);
        }
    }

    String[] entries = new String[CONCEPT_ENTRIES_COUNT + toBeAddedToHeader.size()];
    addFixedEntryHeaders(entries);

    for (int i = 0; i < toBeAddedToHeader.size(); i++) {
        entries[i + CONCEPT_ENTRIES_COUNT] = toBeAddedToHeader.get(i);
    }

    CSVWriter writer = new CSVWriter(osw, ',');
    writer.writeNext(entries);

    DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");

    for (VocabularyConcept c : concepts) {
        int elemPos = 0;
        String value = "";
        List<DataElement> attributeElems = null;

        // add fixed entries
        entries = new String[CONCEPT_ENTRIES_COUNT + toBeAddedToHeader.size()];
        entries[URI_INDEX] = uriPrefix + c.getIdentifier();
        entries[LABEL_INDEX] = c.getLabel();
        entries[DEFINITION_INDEX] = c.getDefinition();
        entries[NOTATION_INDEX] = c.getNotation();
        entries[STATUS_INDEX] = c.getStatus().getLabel();
        entries[ACCEPTED_DATE_INDEX] = c.getAcceptedDate() != null ? dateFormatter.format(c.getAcceptedDate())
                : "";

        // add extra fields
        for (Triple<String, String, Integer> row : attributesMeta) {
            String elemName = row.getLeft();

            attributeElems = VocabularyOutputHelper.getDataElementValuesByNameAndLang(elemName,
                    row.getCentral(), c.getElementAttributes());

            int sizeOfAttributeElems = 0;
            if (attributeElems != null) {
                sizeOfAttributeElems = attributeElems.size();
                for (int j = 0; j < sizeOfAttributeElems; j++) {
                    DataElement e = attributeElems.get(j);
                    if (e.isRelationalElement()) {
                        value = e.getRelatedConceptUri();
                    } else if (StringUtils.isNotEmpty(e.getRelatedConceptIdentifier())
                            && StringUtils.isNotEmpty(e.getDatatype())
                            && e.getDatatype().equalsIgnoreCase("reference")) {
                        value = folderContextRoot + e.getRelatedConceptIdentifier();
                    } else {
                        value = e.getAttributeValue();
                    }
                    // value = "\"" + value + "\"";
                    entries[CONCEPT_ENTRIES_COUNT + elemPos + j] = value;
                }
            }

            int maximumNumberOfElements = row.getRight();
            // add missing columns
            for (int j = sizeOfAttributeElems; j < maximumNumberOfElements; j++) {
                entries[CONCEPT_ENTRIES_COUNT + elemPos + j] = null;
            }

            elemPos += maximumNumberOfElements;
        }
        writer.writeNext(entries);
    }
    writer.close();
    osw.close();
}

From source file:com.clematis.jsmodify.JSExecutionTracer.java

/**
 * This method parses the JSON file containing the trace objects and extracts the objects
 *//*from  ww  w .  ja  v a  2 s.c  o  m*/
public static void extraxtTraceObjects() {
    try {
        ObjectMapper mapper = new ObjectMapper();
        // Register the module that serializes the Guava Multimap
        mapper.registerModule(new GuavaModule());

        Multimap<String, TraceObject> traceMap = mapper.<Multimap<String, TraceObject>>readValue(
                new File("clematis-output/ftrace/function.trace"),
                new TypeReference<TreeMultimap<String, TraceObject>>() {
                });

        Collection<TraceObject> timingTraces = traceMap.get("TimingTrace");
        Collection<TraceObject> domEventTraces = traceMap.get("DOMEventTrace");
        Collection<TraceObject> XHRTraces = traceMap.get("XHRTrace");
        Collection<TraceObject> functionTraces = traceMap.get("FunctionTrace");

        Iterator<TraceObject> it3 = domEventTraces.iterator();
        TraceObject next2;
        ArrayList<TraceObject> removeus = new ArrayList<TraceObject>();
        /**    while (it3.hasNext()) {
        next2 = it3.next();
                
        if (next2 instanceof DOMEventTrace
                && (((DOMEventTrace) next2).getEventType().equals("mouseover") 
                        || (((DOMEventTrace) next2).getEventType().equals("mousemove"))
                        || (((DOMEventTrace) next2).getEventType().equals("mouseout"))
                        || (((DOMEventTrace) next2).getEventType().equals("mousedown"))
                        || (((DOMEventTrace) next2).getEventType().equals("mouseup")))) {
            removeus.add(next2);
                
        }
            }*/
        domEventTraces.removeAll(removeus);

        story = new Story(domEventTraces, functionTraces, timingTraces, XHRTraces);
        story.setOrderedTraceList(sortTraceObjects());

        System.out.println(timingTraces.size());
        Iterator<TraceObject> it = timingTraces.iterator();
        TraceObject next;

        while (it.hasNext()) {
            next = it.next();
            System.out.println("=======");
            System.out.println(next.getCounter());
        }

        /*
         * ArrayList<TraceObject> bookmarkTraceObjects = new ArrayList<TraceObject>(); for
         * (TraceObject to : story.getOrderedTraceList()) { if (to instanceof DOMEventTrace) {
         * if (((DOMEventTrace)to).getEventType().equals("_BOOKMARK_")) {
         * bookmarkTraceObjects.add(to);
         * System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"); } } }
         */

        story.setEpisodes(buildEpisodes());

        ArrayList<Episode> ss = story.getEpisodes();
        Iterator<Episode> it2 = ss.iterator();
        System.out.println("hhhmmm");

        while (it2.hasNext()) {
            System.out.println("--------");
            System.out.println(it2.next().getSource().getClass());
        }

        System.out.println("# of trace objects: " + story.getOrderedTraceList().size());
        System.out.println("# of episodes: " + story.getEpisodes().size());
        /*
         * for (int i = 0; i < story.getEpisodes().size(); i ++) { Episode episode =
         * story.getEpisodes().get(i); if (episode.getSource() instanceof DOMEventTrace) {
         * DOMEventTrace source = (DOMEventTrace)episode.getSource();
         * if(source.getTargetElement().contains("bookmarkButton")) {
         * System.out.println("***********"); if (i + 1 < story.getEpisodes().size()) {
         * story.getEpisodes().get(i).getSource().setIsBookmarked(true); // move isbookmarked to
         * episode System.out.println("* " + story.getEpisodes().get(i).getSource().toString());
         * } } } }
         */
        /*
         * for (int i = 0; i < story.getEpisodes().size(); i ++) { Episode episode =
         * story.getEpisodes().get(i); ArrayList<TraceObject> bookmarkObjects = new
         * ArrayList<TraceObject>(); for (int j = 0; j < episode.getTrace().getTrace().size(); j
         * ++) { if (episode.getTrace().getTrace().get(j) instanceof DOMEventTrace) {
         * DOMEventTrace domEventTrace = (DOMEventTrace)episode.getTrace().getTrace().get(j); if
         * (domEventTrace.getEventType().equals("_BOOKMARK_")) {
         * bookmarkObjects.add(domEventTrace); System.out.println("bookmark"); if (i + 1 <
         * story.getEpisodes().size()) { story.getEpisodes().get(i +
         * 1).getSource().setIsBookmarked(true); } } } }
         * episode.getTrace().getTrace().removeAll(bookmarkObjects); } for (Episode e :
         * story.getEpisodes()) { boolean bookmarkNextEpisode = false; // if
         * (e.getSource().getIsBookmarked()) System.out.println("============ " +
         * e.getSource().getIsBookmarked()); for (TraceObject to : e.getTrace().getTrace()) { if
         * (to instanceof DOMEventTrace) { if
         * (((DOMEventTrace)to).getEventType().equals("_BOOKMARK_"))
         * System.out.println("bookmark"); } } }
         */
        /*
         * for (Episode episode : story.getEpisodes()) { if (episode.getSource() instanceof
         * DOMEventTrace) { if
         * (((DOMEventTrace)episode.getSource()).getTargetElement().contains("bookmarkButton"))
         * { System.out.print("**** " + ((DOMEventTrace)episode.getSource()).getEventType() +
         * " * "); } System.out.println("---- " +
         * ((DOMEventTrace)episode.getSource()).getTargetElement()); } }
         */// TODO TODO TODO project specific for photo gallery. eliminate unwanted episodes
        story.removeUselessEpisodes();

        ss = story.getEpisodes();
        it2 = ss.iterator();
        System.out.println("hhhmmm2");

        while (it2.hasNext()) {
            System.out.println("--------");
            System.out.println(it2.next().getSource().getClass());
        }

        ArrayList<Episode> bookmarkEpisodes = new ArrayList<Episode>();

        for (int i = 0; i < story.getEpisodes().size(); i++) {
            Episode episode = story.getEpisodes().get(i);
            if (episode.getSource() instanceof DOMEventTrace) {
                DOMEventTrace source = (DOMEventTrace) episode.getSource();
                if (source.getTargetElement().contains("bookmarkButton")) {
                    bookmarkEpisodes.add(episode);
                    if (i + 1 < story.getEpisodes().size()) {
                        story.getEpisodes().get(i + 1).setIsBookmarked(true);
                        // story.getEpisodes().get(i).getSource().setIsBookmarked(true); // move
                        // isbookmarked to episode
                        System.out.println("* episode # " + (i + 1) + " bookmarked");
                    }
                }
            }

        }

        story.removeUselessEpisodes(bookmarkEpisodes);

        //    story.removeToolbarEpisodes();

        System.out.println("# of episodes after trimming: " + story.getEpisodes().size());

        DateFormat dateFormat = new SimpleDateFormat("EEE,d,MMM,HH-mm");
        Date date = new Date();
        System.out.println(dateFormat.format(date));
        // dateFormat.format(date).toString()
        theTime = new String(dateFormat.format(date).toString());
        System.out.println(theTime);

        // JavaScript episodes for JSUML2
        Helper.directoryCheck(outputFolder + "/sequence_diagrams/");
        PrintStream JSepisodes = new PrintStream(outputFolder + "/sequence_diagrams/allEpisodes.js");

        for (Episode e : story.getEpisodes()) {
            // Create pic files for each episode's sequence diagram
            designSequenceDiagram(e, JSepisodes);
        }

        // Once all episodes have been saved to JS file, close
        JSepisodes.close();

        // Create graph containing all episodes with embedded sequence diagrams
        EpisodeGraph eg = new EpisodeGraph(getOutputFolder(), story.getEpisodes());
        eg.createGraph();
        writeStoryToDisk();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.zimbra.cs.service.util.ItemDataFile.java

public static void list(InputStream is, Set<MailItem.Type> types, String cset, PrintStream os)
        throws IOException {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    TarEntry te;//w  w w .  j ava 2  s.c om
    TarInputStream tis = new TarInputStream(new GZIPInputStream(is), cset == null ? "UTF-8" : cset);

    os.format("%-13s %17s %10s %6s %s\n", "TYPE", "DATE", "SIZE", "METASZ", "PATH");
    try {
        TarEntry idEntry = null;

        while ((te = tis.getNextEntry()) != null) {
            if (te.getName().endsWith(".meta")) {
                if (idEntry != null && !skip(types, MailItem.Type.of((byte) idEntry.getMajorDeviceId()))) {
                    os.format("%-13s %17s %10s %6d %s\n", idEntry.getGroupName(),
                            df.format(idEntry.getModTime()), 0, idEntry.getSize(),
                            idEntry.getName().substring(0, idEntry.getName().indexOf(".meta")));
                }
                idEntry = te;
            } else {
                if (!skip(types, MailItem.Type.of((byte) te.getMajorDeviceId()))) {
                    os.format("%-13s %17s %10s %6d %s\n", te.getGroupName(), df.format(te.getModTime()),
                            te.getSize(), idEntry == null ? 0 : idEntry.getSize(), te.getName());
                }
                idEntry = null;
            }
        }
        if (idEntry != null && !skip(types, MailItem.Type.of((byte) idEntry.getMajorDeviceId()))) {
            os.format("%-13s %17s %10s %6d %s\n", idEntry.getGroupName(), df.format(idEntry.getModTime()), 0,
                    idEntry.getSize(), idEntry.getName().substring(0, idEntry.getName().indexOf(".meta")));
        }
    } finally {
        tis.close();
    }
}

From source file:com.aurel.track.exchange.msProject.exchange.MsProjectExchangeBL.java

/**
 * Parse the date according to dateFormat
 *///from ww  w . j av a2s  .  com
public static String formatDateTime(Date date) {
    DateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    if (date != null) {
        try {
            return dateTimeFormat.format(date);
        } catch (Exception e) {
            LOGGER.debug(e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return "";
}

From source file:com.alkacon.opencms.calendar.CmsSerialDateWidget.java

/**
 * Returns the given timestamp as String formatted in a localized pattern.<p>
 * /*from  w  w  w .j  a  v a  2  s . c o m*/
 * @param locale the locale for the time format
 * @param messages the messages that contain the time format definitions
 * @param timestamp the time to format
 * @param showDate flag to show the date in the formatted String
 * @param showTime flag to show the time in the formatted String
 * 
 * @return the given timestamp as String formatted in a localized pattern
 */
public static String getCalendarLocalizedTime(Locale locale, CmsMessages messages, long timestamp,
        boolean showDate, boolean showTime) {

    // get the current date & time 
    TimeZone zone = TimeZone.getDefault();
    GregorianCalendar cal = new GregorianCalendar(zone, locale);
    cal.setTimeInMillis(timestamp);
    String datePattern = "";
    if (showDate) {
        datePattern = messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_DATE_FORMAT_0);
        if (showTime) {
            datePattern += " ";
        }
    }
    if (showTime) {
        datePattern += messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_TIME_FORMAT_0);
    }
    // format it nicely according to the localized pattern
    DateFormat df = new SimpleDateFormat(CmsCalendarWidget.getCalendarJavaDateFormat(datePattern));
    return df.format(cal.getTime());
}

From source file:com.tencent.wetest.common.util.ReportUtil.java

@SuppressLint("SimpleDateFormat")
public static synchronized String saveReport() {

    try {/* www. ja v  a 2s .c  om*/

        path = WTApplication.getContext().getFilesDir().getPath();
        String versionName = ((WTApplication) WTApplication.getContext()).getApkinfo().getVersionName();

        packageName = ((WTApplication) WTApplication.getContext()).getApkinfo().getPackagename();
        appName = ((WTApplication) WTApplication.getContext()).getApkinfo().getAppname();
        ;
        datasource = ((WTApplication) WTApplication.getContext()).getReport();

        if (datasource != null)
            datas = datasource.getDatalist();

        size = datas.size();

        Date now = new Date();

        long timeStart = -1;
        long timeEnd = -1;
        boolean hasBaseTime = false;

        if (datasource.getBaseTime() == -1) {

            hasBaseTime = false;

            timeEnd = (new Date()).getTime();

            if (timeEnd == -1) {

                timeEnd = now.getTime();

                timeStart = (timeEnd - (SystemClock.uptimeMillis() - datasource.getBaseColock()))
                        + (datasource.getTimeStart() - datasource.getBaseColock());

            } else {

                timeStart = (timeEnd - (SystemClock.uptimeMillis() - datasource.getBaseColock()))
                        + (datasource.getTimeStart() - datasource.getBaseColock());

                ((WTApplication) WTApplication.getContext()).getReport().setBaseTime(timeEnd);
                ((WTApplication) WTApplication.getContext()).getReport()
                        .setBaseColock(SystemClock.uptimeMillis());

            }

        } else {

            hasBaseTime = true;

            timeStart = datasource.getBaseTime() + datasource.getTimeStart() - datasource.getBaseColock();

            timeEnd = datasource.getBaseTime() + SystemClock.uptimeMillis() - datasource.getBaseColock();

        }

        File f;
        File indexfile = new File(path + "/wtIndex");

        if (((WTApplication) WTApplication.getContext()).getCurrTestFile() == null) {

            name = "wt" + now.getTime();

            String fileDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/wetest";
            ToolUtil.createDir(fileDir);

            f = new File(fileDir + "/" + name);
            ((WTApplication) WTApplication.getContext()).setCurrTestFile(f);

        } else {
            f = ((WTApplication) WTApplication.getContext()).getCurrTestFile();
            name = f.getName();

        }

        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String isRoot = ((WTApplication) WTApplication.getContext()).isRoot() ? "1" : "0";

        String content_index = name + "/" + formatter.format(timeEnd) + "/" + appName.replaceFirst("\\s+", "")
                + "/" + packageName + "/" + (timeEnd - timeStart) / 1000 + "/" + timeStart + "/" + timeEnd + "/"
                + versionName + "/" + isRoot + "/" + "";

        ((WTApplication) WTApplication.getContext()).getTestReports().add(name);

        if (!f.exists()) {
            f.createNewFile();
        }

        if (!indexfile.exists())
            indexfile.createNewFile();

        JsonResult json_res = readFileReport(f);

        JSONObject cpu = new JSONObject();

        JSONObject natived = new JSONObject();
        JSONObject dalvik = new JSONObject();
        JSONObject total = new JSONObject();

        JSONObject networkIn = new JSONObject();
        JSONObject networkOut = new JSONObject();

        JSONObject fps = new JSONObject();

        JSONObject time = new JSONObject();

        JSONObject tag = new JSONObject();

        JSONObject temperature = new JSONObject();

        JSONObject current = new JSONObject();

        for (ReportData data : datas) {

            if (!hasBaseTime) {

                long gap = data.getTime() - datasource.getTimeStart();

                long offset = gap > 0 ? gap : 0;

                json_res.getContent_f_time().put((timeStart + offset) / 1000);

                //Logger.debug("dataTime is " + formatter.format(timeStart + offset));

            } else {

                json_res.getContent_f_time().put((data.getTime()) / 1000);

                //Logger.debug("dataTime is " + formatter.format(data.getTime()));

            }

            json_res.getContent_f_cpu().put(data.getCpu());

            json_res.getContent_f_native().put(data.getpNative());
            json_res.getContent_f_dalvik().put(data.getpDalvik());
            json_res.getContent_f_total().put(data.getpTotal());

            json_res.getContent_f_networkIn().put(data.getpNetworUsagekIn());
            json_res.getContent_f_networkOut().put(data.getpNetworUsagekOut());
            json_res.getContent_f_Fps().put(data.getFps());

            json_res.getContent_f_Tag().put(data.getTag());

            json_res.getContent_f_temperature().put(data.getpTemperature());

            json_res.getContent_f_current().put(data.getpCurrent());

        }

        cpu.put("cpu", json_res.getContent_f_cpu());

        natived.put("native", json_res.getContent_f_native());
        dalvik.put("dalvik", json_res.getContent_f_dalvik());
        total.put("total", json_res.getContent_f_total());

        networkIn.put("networkIn", json_res.getContent_f_networkIn());
        networkOut.put("networkOut", json_res.getContent_f_networkOut());
        time.put("time", json_res.getContent_f_time());

        fps.put("fps", json_res.getContent_f_Fps());
        tag.put("tag", json_res.getContent_f_Tag());

        temperature.put("temperature", json_res.getContent_f_temperature());
        current.put("current", json_res.getContent_f_current());

        BufferedWriter writer = new BufferedWriter(new FileWriter(f, false));

        writer.append(cpu.toString());
        writer.newLine();

        writer.append(natived.toString());
        writer.newLine();

        writer.append(dalvik.toString());
        writer.newLine();

        writer.append(total.toString());
        writer.newLine();

        writer.append(networkIn.toString());
        writer.newLine();

        writer.append(networkOut.toString());
        writer.newLine();

        writer.append(time.toString());
        writer.newLine();

        writer.append(fps.toString());
        writer.newLine();

        writer.append(tag.toString());

        writer.flush();
        writer.close();

        updateRecord(indexfile, name, content_index);

    } catch (Exception e) {
        Logger.error("report save exception :" + e.toString());
        e.printStackTrace();
    }

    return name;

}

From source file:de.fu_berlin.inf.dpp.feedback.SessionStatistic.java

private static String toISO8601UTCTimeFormat(Date date) {
    TimeZone timeZone = TimeZone.getTimeZone("UTC");
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    dateFormat.setTimeZone(timeZone);//from ww  w . ja  va  2 s . co  m
    return dateFormat.format(date);
}