Package java.text

Examples of java.text.Format$Field


      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


        }
        // 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

    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

    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

  }

  public String getCurrentDateAsString(FacesContext context,
      UICalendar calendar, Date date) throws IOException {

    Format formatter = new SimpleDateFormat("MM/yyyy");
    return formatter.format(date);
  }
View Full Code Here

     * @param pattern The pattern used to format the value.
     * @param locale The locale to use for the Format.
     * @return The value formatted as a <code>String</code>.
     */
    public String format(Object value, String pattern, Locale locale) {
        Format formatter = getFormat(pattern, locale);
        return format(value, formatter);
    }
View Full Code Here

     * @param valueToFormat value to process and convert to String
     * @throws JspException if a JSP exception has occurred
     */
    protected String formatValue(Object valueToFormat)
        throws JspException {
        Format format = null;
        Object value = valueToFormat;
        Locale locale =
            TagUtils.getInstance().getUserLocale(pageContext, this.localeKey);
        boolean formatStrFromResources = false;
        String formatString = formatStr;

        // Return String object as is.
        if (value instanceof java.lang.String) {
            return (String) value;
        } else {
            // Try to retrieve format string from resources by the key from
            // formatKey.
            if ((formatString == null) && (formatKey != null)) {
                formatString = retrieveFormatString(this.formatKey);

                if (formatString != null) {
                    formatStrFromResources = true;
                }
            }

            // Prepare format object for numeric values.
            if (value instanceof Number) {
                if (formatString == null) {
                    if ((value instanceof Byte) || (value instanceof Short)
                        || (value instanceof Integer)
                        || (value instanceof Long)
                        || (value instanceof BigInteger)) {
                        formatString = retrieveFormatString(INT_FORMAT_KEY);
                    } else if ((value instanceof Float)
                        || (value instanceof Double)
                        || (value instanceof BigDecimal)) {
                        formatString = retrieveFormatString(FLOAT_FORMAT_KEY);
                    }

                    if (formatString != null) {
                        formatStrFromResources = true;
                    }
                }

                if (formatString != null) {
                    try {
                        format = NumberFormat.getNumberInstance(locale);

                        if (formatStrFromResources) {
                            ((DecimalFormat) format).applyLocalizedPattern(
                                formatString);
                        } else {
                            ((DecimalFormat) format).applyPattern(formatString);
                        }
                    } catch (IllegalArgumentException e) {
                        JspException ex =
                            new JspException(messages.getMessage(
                                    "write.format", formatString));

                        TagUtils.getInstance().saveException(pageContext, ex);
                        throw ex;
                    }
                }
            } else if (value instanceof java.util.Date) {
                if (formatString == null) {
                    if (value instanceof java.sql.Timestamp) {
                        formatString =
                            retrieveFormatString(SQL_TIMESTAMP_FORMAT_KEY);
                    } else if (value instanceof java.sql.Date) {
                        formatString =
                            retrieveFormatString(SQL_DATE_FORMAT_KEY);
                    } else if (value instanceof java.sql.Time) {
                        formatString =
                            retrieveFormatString(SQL_TIME_FORMAT_KEY);
                    } else if (value instanceof java.util.Date) {
                        formatString = retrieveFormatString(DATE_FORMAT_KEY);
                    }
                }

                if (formatString != null) {
                    format = new SimpleDateFormat(formatString, locale);
                }
            }
        }

        if (format != null) {
            return format.format(value);
        } else {
            return value.toString();
        }
    }
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

TOP

Related Classes of java.text.Format$Field

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.