Package java.text

Examples of java.text.Format


        value = (value == null ? null : value.trim());
        if (value == null || value.length() == 0) {
            return null;
        }
        Format formatter = getFormat(pattern, locale);
        return parse(value, formatter);

    }
View Full Code Here


    if (locale != null)
    {
      error.setVariable("locale", locale);
    }
    error.setVariable("exception", e);
    Format format = e.getFormat();
    if (format instanceof SimpleDateFormat)
    {
      error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
    }
View Full Code Here

      error.setVariable("locale", locale);
    }

    error.setVariable("exception", cause);

    Format format = cause.getFormat();
    if (format instanceof SimpleDateFormat)
    {
      error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
    }
View Full Code Here

  private int findFirstDateFormat(final Format[] formats)
  {
    for (int j = 0; j < formats.length; j++)
    {
      final Format format = formats[j];
      if (format instanceof SimpleDateFormat)
      {
        return j;
      }
    }
View Full Code Here

  private int findFirstNumberFormat(final Format[] formats)
  {
    for (int j = 0; j < formats.length; j++)
    {
      final Format format = formats[j];
      if (format instanceof DecimalFormat)
      {
        return j;
      }
    }
View Full Code Here

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = mockComponentResources();

        Format format = new Format()
        {
            private static final long serialVersionUID = -4360045992642727894L;

            @Override
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
View Full Code Here

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = mockComponentResources();

        Format format = new Format()
        {
            @Override
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
            {
                return toAppendTo;
View Full Code Here

            // Calculate appropriate time, add it to the submap, then
            // add
            // that to the tempMap
            subMap.put("snapshot_time", ((Long) mapTimeFix.get("times").get(
                    "snapshot_time") - (getSnapshotDuration() * skipCount)));
            Format formatter = null;
            formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date((Long) subMap.get("snapshot_time"));
            subMap.put("snapshot_date", formatter.format(date));

            // Add the submap back to the tempmap
            tempMap.put("times", new HashMap<String, Object>(subMap));

            // Clear out the subMap for use again
            subMap.clear();

            // Run through the mbeans

            // Run through the mbeans
            for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
                    .hasNext();) {
                // get the mbean name
                String mbeanName = it.next();
                HashMap<String, Object> stats = null;
                // Verify that it's not times

                if (mbeanName.equals(new String("times"))) {

                } else {
                    stats = mapTimeFix.get(mbeanName);
                    // Run through the stats elements for the particular
                    // mbean
                    for (Iterator<String> itt = stats.keySet().iterator(); itt
                            .hasNext();) {
                        String key = itt.next();
                        // Place faux data into the submap
                        subMap.put(key, new Long(0));
                    }
                    // Add the submap to the tempmap, and clear it
                    tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
                }
            }
            snapshotList.add(0, new HashMap<String, HashMap<String, Object>>(
                    tempMap));
        }

        /*
         * This is where we will be inserting data to fill 'gaps' in the
         * snapshots The initial for-loop will travel from the most recent
         * snapshot to the oldest, checking that the snapshot_time along the way
         * all align with what they should be
         */
        for (int i = snapshotList.size() - 1; i > 0; i--) {
            if (i > 0) {
                HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
                        .get(i);
                HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
                        .get(i - 1);
                // here is where we will in missing data
                while (((((Long) mapTimeFix.get("times").get("snapshot_time") / 1000) / 60)
                        - (((Long) mapTimeFix2.get("times")
                                .get("snapshot_time") / 1000) / 60) > (((getSnapshotDuration() / 1000) / 60) * skipCount))) {
                    HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
                    HashMap<String, Object> subMap = new HashMap<String, Object>();

                    for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
                            .hasNext();) {
                        // get the mbean name
                        String mbeanName = it.next();
                        HashMap<String, Object> stats = null;
                        // Verify that it's not times
                        if (!mbeanName.equals("times")) {
                            stats = mapTimeFix.get(mbeanName);
                            // Run through the stats elements for the
                            // particular
                            // mbean
                            for (Iterator<String> itt = stats.keySet()
                                    .iterator(); itt.hasNext();) {
                                String key = itt.next();
                                // Place faux data into the submap
                                subMap.put(key, new Long(0));
                            }
                            // Add the submap to the tempmap, and clear it
                            tempMap.put(mbeanName, new HashMap<String, Object>(
                                    subMap));
                            subMap.clear();
                        }
                    }

                    subMap.put("snapshot_time", new Long((Long) mapTimeFix.get(
                            "times").get("snapshot_time")
                            - (getSnapshotDuration() * skipCount)));
                    Format formatter = null;
                    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date date = new Date((Long) subMap.get("snapshot_time"));
                    subMap.put("snapshot_date", formatter.format(date));
                    tempMap.put("times", new HashMap<String, Object>(subMap));
                    subMap.clear();
                    snapshotList.add(i,
                            new HashMap<String, HashMap<String, Object>>(
                                    tempMap));
View Full Code Here

                + "graph" + graph.getId()
                + ".addPlot(\"default\", {type: \"Areas\", tension:3});\n" + "graph"
                + graph.getId() + ".setTheme(dojox.charting.themes.PlotKit.blue);\n";

        // Setup the x tick marks on the chart
        Format formatter;
        if ((graph.getTimeFrame() / 1440) > 7)
            formatter = new SimpleDateFormat("M/d");
        else {
            if ((graph.getTimeFrame() / 60) > 24)
                formatter = new SimpleDateFormat("E a");
            else {
                formatter = new SimpleDateFormat("HH:mm");
            }
        }
        GraphJS += "graph" + graph.getId() + ".addAxis(\"x\", {labels: [";
        for (int i = 1; i < dataSet1.size(); i++) {
            Date date = new Date(snapshotTimes.get(i));
            GraphJS += "{value: " + (i) + ", text: '" + formatter.format(date);
            if ((i+1) != dataSet1.size())
                GraphJS += "' }, \n";
            else
              GraphJS += "' } \n";
        }
View Full Code Here

        if (field.isVisible(session, object, where).isVetoed()) {
            throw new ForbiddenException(field, ForbiddenException.VISIBLE);
        }

        String pattern = request.getOptionalProperty("decimal-format");
        Format format = null;
        if (pattern != null) {
            format = new DecimalFormat(pattern);
        }
        pattern = request.getOptionalProperty("date-format");
        if (pattern != null) {
View Full Code Here

TOP

Related Classes of java.text.Format

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.