Package java.text

Examples of java.text.Format$FieldDelegate


     * Returns a shared instance of {@link AngleFormat}. The return type is
     * {@link Format} in order to avoid class loading before necessary.
     */
    private static synchronized Format getAngleFormat() {
        if (format!=null) {
            final Format angleFormat = (Format) format.get();
            if (angleFormat!=null) {
                return angleFormat;
            }
        }
        final Format newFormat = new AngleFormat("D\u00b0MM.m'", Locale.US);
        format = new SoftReference<Format>(newFormat);
        return newFormat;
    }
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

  private String toText(Object value, Object object) {
    if (value == null)
      return EMPTY_STRING;
    if (defaultValue != null && hideZeroValues && defaultValue.equals(value))
      return EMPTY_STRING;
    Format f = getFormat(object);
    if (f != null) {
      return f.format(value);
    } else {
      if (isHyperlink())
        return ((Hyperlink)value).toString();
      return FieldConverter.toString(value, getDisplayType(), null); // Convert
                                      // to
View Full Code Here

    // log.warn("Tried to set text of read only field" + getId());
      return;
    }
    Object value = preprocessText(object, textValue, context);
    if (value == textValue) {
      Format f = getFormat(object);
      if (f != null) {
        try {
          value = f.parseObject(textValue);
        } catch (ParseException e) {
          f = getSecondaryFormat(object); // allow money to parse as number too
          boolean secondOK = false;
          if (f != null) {
            try {
              value = f.parseObject(textValue);
              secondOK = true;
            } catch (ParseException e1) {
            }
          }
          if (!secondOK)
View Full Code Here

      return;
    }
    Object object = node.getImpl();
    Object value = preprocessText(object, textValue, context);
    if (value == textValue) {
      Format f = getFormat(object);
      if (f != null) {
        try {
          value = f.parseObject(textValue);
        } catch (ParseException e) {
          throw new FieldParseException(e);
        }
      } else {
        value = FieldConverter.convert(textValue, hasExternalType() ? externalType : internalType, context); // converts
View Full Code Here

    /**
     * Ensures that the parse/format separation is correctly maintained.
     */
    public void testCompositeFormat() {

        Format parser = new Format() {
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
                throw new UnsupportedOperationException("Not implemented");
            }

            public Object parseObject(String source, ParsePosition pos) {
                return null;    // do nothing
            }
        };

        Format formatter = new Format() {
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
                return null;    // do nothing
            }

            public Object parseObject(String source, ParsePosition pos) {
View Full Code Here

        assertEquals( "Parser get method incorrectly implemented", parser, composite.getParser() );
        assertEquals( "Formatter get method incorrectly implemented", formatter, composite.getFormatter() );
    }

    public void testUsage() throws Exception {
        Format f1 = new SimpleDateFormat("MMddyyyy", Locale.ENGLISH);
        Format f2 = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
        CompositeFormat c = new CompositeFormat(f1, f2);
        String testString = "January 3, 2005";
        assertEquals(testString, c.format(c.parseObject("01032005")));
        assertEquals(testString, c.reformat("01032005"));
    }
View Full Code Here

   * @return
   */
  private String append(Object... params){
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.FRENCH);
    numberFormat.setMaximumFractionDigits(1);
    Format formatter = new SimpleDateFormat(Constants.DATE_FORMAT);
    String srcParam = "";
    for(Object param : params){
      if(param != null){
        if(param instanceof String){
          srcParam += param;
        }
        if(param instanceof Double){
          srcParam += numberFormat.format(param);
        }
        if(param instanceof Float){
          srcParam += numberFormat.format(param);
        }
        if(param instanceof Date){
          srcParam += formatter.format(param);
        }
      } else{
        srcParam += "null";
      }
      srcParam += Constants.SEPRATE;
View Full Code Here

   */
  private String append(Object... params){
    numberFormat = NumberFormat.getInstance(Locale.FRENCH);
    numberFormat.setMaximumFractionDigits(1)
    dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT);
    Format formatter = new SimpleDateFormat(Constants.DATE_FORMAT);
    String srcParam = "";
    for(Object param : params){
      if(param != null){
        if(param instanceof String){
          srcParam += param;
        }
        if(param instanceof Double){
          srcParam += numberFormat.format(param);
        }
        if(param instanceof Float){
          srcParam += numberFormat.format(param);
        }
        if(param instanceof Date){
          srcParam += formatter.format(param);
        }
      } else{
        srcParam += "null";
      }
      srcParam += Constants.SEPRATE;
View Full Code Here

        formats = new HashMap<String,Format>();

        // init built-in formats

        Format zipFormat = ZipPlusFourFormat.instance;
        addFormat("00000\\-0000", zipFormat);
        addFormat("00000-0000", zipFormat);

        Format phoneFormat = PhoneFormat.instance;
        // allow for format string variations
        addFormat("[<=9999999]###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
        addFormat("[<=9999999]###-####;(###) ###-####", phoneFormat);
        addFormat("###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
        addFormat("###-####;(###) ###-####", phoneFormat);

        Format ssnFormat = SSNFormat.instance;
        addFormat("000\\-00\\-0000", ssnFormat);
        addFormat("000-00-0000", ssnFormat);
    }
View Full Code Here

TOP

Related Classes of java.text.Format$FieldDelegate

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.