Package java.text

Examples of java.text.Format.format()


        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[]{
                new DataInputStream(new ByteArrayInputStream(new byte[]{0, 'A', 0, 'n', 0, ' '})),
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

                    row.set(IsSqlEnabled.name, false);
                    row.set(Description.name, desc);
                    Format formatter =
                        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                    String formattedDate =
                        formatter.format(schema.getSchemaLoadDate());
                    row.set(LastSchemaUpdate.name, formattedDate);
                    if (deep) {
                        row.set(
                            Dimensions.name,
                            new MdschemaDimensionsRowset(
View Full Code Here

        }
        else
        {
            try
            {
                insert = format.format(value);
            }
            catch (Exception ex)
            {
                throw new ApplicationRuntimeException(ComponentMessages
                        .unableToFormat(this, value, ex), this, getBinding(
View Full Code Here

        // Get a new format each time, because (a) have to account for locale and (b) formatters are
        // not thread safe.

        Format format = getFormat(locale);

        return format.format(object);
    }

    /**
     * @see org.apache.tapestry.form.translator.AbstractTranslator#parseText(org.apache.tapestry.form.IFormComponent,
     *      ValidationMessages, java.lang.String)
View Full Code Here

            value = new DefaultCaret();
            assertEquals(value.toString(), formatter.valueToString(value));
            Format format = NumberFormat.getPercentInstance();
            formatter.setFormat(format);
            value = new Integer(456);
            assertEquals(format.format(value), formatter.valueToString(value));
            format = NumberFormat.getCurrencyInstance();
            formatter.setFormat(format);
            value = new Integer(345);
            assertEquals(format.format(value), formatter.valueToString(value));
        } catch (ParseException e) {
View Full Code Here

            value = new Integer(456);
            assertEquals(format.format(value), formatter.valueToString(value));
            format = NumberFormat.getCurrencyInstance();
            formatter.setFormat(format);
            value = new Integer(345);
            assertEquals(format.format(value), formatter.valueToString(value));
        } catch (ParseException e) {
            assertTrue("Unexpected exception: ", false);
        }
    }
View Full Code Here

        }
        else
        {
            try
            {
                insert = format.format(value);
            }
            catch (Exception ex)
            {
                throw new ApplicationRuntimeException(ComponentMessages.unableToFormat(
                        this,
View Full Code Here

        Connection conn = DriverManager.getConnection(url, props);
        try {
            PreparedStatement statement = conn.prepareStatement(query);
            ResultSet rs = statement.executeQuery();
            assertTrue(rs.next());
            assertEquals(dateFormatter.format(D1), rs.getString(2));
        } finally {
            conn.close();
        }
    }
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.