Package java.text

Examples of java.text.Format


      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


      }
      // Fill the information about the certificates
      Enumeration<String> aliases = keyStore.aliases();
      List<org.wso2.carbon.security.keystore.service.CertData> certDataList = new ArrayList<CertData>();
      Format formatter = new SimpleDateFormat("dd/MM/yyyy");

      while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if (keyStore.isCertificateEntry(alias)) {
          X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias);
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

public class FailoverToyExample {

    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)));
    }
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

                    row.set(IsDrillthroughEnabled.name, true);
                    row.set(IsWriteEnabled.name, false);
                    row.set(IsLinkable.name, false);
                    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

                    // The idea is to try and convert strings into the
                    // types of objects that the formatters expects
                    // i.e. Numbers and Dates
                    Format[] formats = messageFormat.getFormats();
                    for (int i = 0; i < formats.length; i++) {
                        Format format = formats[i];
                        if (format != null) {
                            if (format instanceof DateFormat) {
                                if (arguments.size() > i) {
                                    Object val = arguments.get(i);
                                    if (val instanceof String) {
View Full Code Here

        if (value == null) return;

        String insert = null;

        Format format = getFormat();

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

    protected String formatObject(IFormComponent field, Locale locale, Object object)
    {
        // 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);
    }
View Full Code Here

     *      ValidationMessages, java.lang.String)
     */
    protected Object parseText(IFormComponent field, ValidationMessages messages, String text)
            throws ValidatorException
    {
        Format format = getFormat(messages.getLocale());
       
        try
        {
            return format.parseObject(text);
        }
        catch (ParseException ex)
        {
            throw new ValidatorException(buildMessage(messages, field, getMessageKey()),
                    getConstraint());
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.