Package java.text

Examples of java.text.Format.format()


        Format numberFormat = getFormat(cell);
        double d = cell.getNumericCellValue();
        if (numberFormat == null) {
            return String.valueOf(d);
        }
        return numberFormat.format(new Double(d));
    }

    /**
     * Formats the given raw cell value, based on the supplied
     *  format index and string, according to excel style rules.
View Full Code Here


            Format numberFormat = getFormat(value, formatIndex, formatString);
            if (numberFormat == null) {
                return String.valueOf(value);
            }
            // RK: This hack handles scientific notation by adding the missing + back.
            String result = numberFormat.format(new Double(value));
            if (result.contains("E") && !result.contains("E-")) {
                result = result.replaceFirst("E", "E+");
            }
            return result;
    }
View Full Code Here

                if (needsConfigure) {
                    configure(format, s);
                }
                table.append(beforeFill);
                table.nextColumn(fillCharacter);
                table.append(format.format(value));
                table.setCellAlignment(TableAppender.ALIGN_RIGHT);
            }
            table.append(lineSeparator);
        }
        if (horizontalLine != 0) {
View Full Code Here

                }
                if (characterIterator != null) {
                    ((FormattedCharacterIterator) characterIterator)
                            .append(format.formatToCharacterIterator(value), toAppendTo);
                } else {
                    format.format(value, toAppendTo, new FieldPosition(-1));
                }
            }
            /*
             * At this point, the field has been formatted. Now store the field index,
             * then append the separator between this field and the next one.
View Full Code Here

    slider.setPaintTicks(true);
    slider.setSnapToTicks(false);
    Format f = new DecimalFormat("0.0");
    Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>();
    for (int i = 0; i <= 10; i += 2) {
      JLabel label = new JLabel(f.format(i));
      label.setFont(label.getFont().deriveFont(Font.PLAIN));
      labels.put(i * 10, label);
    }
    slider.setLabelTable(labels);
    slider.addChangeListener(new ChangeListener() {
View Full Code Here

        }
        // Run Object through formatter to get String.
        // This provides a simple way of getting a reasonable string representation
        // for types like DATE and TIME
        Format formatter = statement.getFormatter(type);
        return formatter == null ? value.toString() : formatter.format(value);
    }

    @Override
    public String getString(String columnLabel) throws SQLException {
        return getString(findColumn(columnLabel));
View Full Code Here

        // 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());
            }
        }
View Full Code Here

            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

    public static void packageOverviewExample1() {
        Format[] formats = new Format[]{
                NumberFormat.getInstance(), DateFormat.getDateInstance(), new MessageFormat("{1}, {0}"),};
        Format format = (Format)Failover.object(Format.class, new CglibProxyFactory(), formats, RuntimeException.class);
        System.out.println("Format a date: " + format.format(new Date()));
        System.out.println("Format a message: " + format.format(new String[]{"John", "Doe"}));
        System.out.println("Format a number: " + format.format(new Integer(42)));
    }

    public static void packageOverviewExample2() {
View Full Code Here

    public static void packageOverviewExample1() {
        Format[] formats = new Format[]{
                NumberFormat.getInstance(), DateFormat.getDateInstance(), new MessageFormat("{1}, {0}"),};
        Format format = (Format)Failover.object(Format.class, new CglibProxyFactory(), formats, RuntimeException.class);
        System.out.println("Format a date: " + format.format(new Date()));
        System.out.println("Format a message: " + format.format(new String[]{"John", "Doe"}));
        System.out.println("Format a number: " + format.format(new Integer(42)));
    }

    public static void packageOverviewExample2() {
        DataInput[] dataInputs = new DataInput[]{
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.