Package java.text

Examples of java.text.Format


   */
  protected Format getNumberFormat(String pattern)
  {
    Locale lc = getLocale();
    String key = pattern + "|" + JRDataUtils.getLocaleCode(lc);
    Format format = (Format)numberFormatCache.get(key);
    if (format == null)
    {
      format = getFormatFactory().createNumberFormat(pattern, lc);
      if (format != null)
      {
View Full Code Here


  public void add(String field, Format formatting) {
    this.formatting.put(field, formatting);
  }
 
  public String format(String field, Object object) {
    Format format = (Format)this.formatting.get(field);
   
    if(object == null) return field + " is null and could not be formatted.";
    if(format == null) return object.toString();
   
    try {
      return format.format(object);
    } catch(Exception q) {
      return "Formatting error: " + q.getMessage();
    }
  }
View Full Code Here

                                                             UserPreferences preferences) {
    InternationalFormatter formatter;
    if (editableProperty == PlanController.EditableProperty.ANGLE) {     
      formatter = new NumberFormatter(NumberFormat.getNumberInstance());
    } else {
      Format lengthFormat = preferences.getLengthUnit().getFormat();
      if (lengthFormat instanceof NumberFormat) {
        formatter = new NumberFormatter((NumberFormat)lengthFormat);
      } else {
        formatter = new InternationalFormatter(lengthFormat);
      }
View Full Code Here

        //Irrespective of the scope ,if the dateformat has provided ,
        // should return the Date according to the provided format

        if (SynapseConstants.SYSTEM_DATE.equals(key)) {
            if (dateformat != null) {
                Format formatter = new SimpleDateFormat(dateformat.toString());
                return formatter.format(new java.util.Date());
            } else {
                Format formatter = new SimpleDateFormat();
                return formatter.format(new java.util.Date());
            }
        }

        //return the current system time as a string , don't care scope
        if (SynapseConstants.SYSTEM_TIME.equals(key)) {
View Full Code Here

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

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

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

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

        }
        // when the code has reach this point, a connection was successfully
        // established
        // so we need to update the last_seen attribute for the server
        Format formatter = null;
        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date(System.currentTimeMillis());
        String currentTime = formatter.format(date);

        Connection conn = DBManager.createConnection();
        try {
            Statement stmt = conn.createStatement();
            stmt.executeUpdate("UPDATE SERVERS SET LAST_SEEN = '" + currentTime
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

        }

        // check to see if graph was successfully populated
        if (graph != null) {
            // get the current date
            Format formatter = null;
            formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(System.currentTimeMillis());
            String currentTime = formatter.format(date);
            // the graph was successfully operated on,
            // so update the last_seen attribute
            DBManager dbManager = new DBManager();
            Connection conn = dbManager.getConnection();
            Statement stmt = conn.createStatement();
View Full Code Here

    subscribers.remove(subscriber);
  }

  //Formats a Unix timestamp according to RFC 3339
  private String formatTime(long time) {
    final Format format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    String date = format.format(new Date(time));
    //Z doesn't include a colon between the hour and the minutes
    return date.substring(0, 22) + ":" + date.substring(22);
  }
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.