Package java.text

Examples of java.text.Format$Field


  }

  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


  }

  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

     * Check only using specified lenient future dates setting
     */
    private void checkShortParse(String msg, Calendar now, Calendar input, boolean lenient) throws ParseException {
        FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
        parser.setLenientFutureDates(lenient);
        Format shortFormat = parser.getRecentDateFormat(); // It's expecting this format
        Format longFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");

        final String shortDate = shortFormat.format(input.getTime());
        Calendar output=parser.parseTimestamp(shortDate, now);
        int outyear = output.get(Calendar.YEAR);
        int outdom = output.get(Calendar.DAY_OF_MONTH);
        int outmon = output.get(Calendar.MONTH);
        int inyear = input.get(Calendar.YEAR);
        int indom = input.get(Calendar.DAY_OF_MONTH);
        int inmon = input.get(Calendar.MONTH);
        if (indom != outdom || inmon != outmon || inyear != outyear){
            fail("Test: '"+msg+"' Server="+longFormat.format(now.getTime())
                    +". Failed to parse "+shortDate
                    +". Actual "+longFormat.format(output.getTime())
                    +". Expected "+longFormat.format(input.getTime()));
        }
    }
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

   */
  public static String convertToDecimalNotation(String numberAsString) {
    // Check for a scientific notation delimiter.
    if (numberAsString.indexOf("E") != -1
        || numberAsString.indexOf("e") != -1) {
      Format format = new DecimalFormat(UNROUNDED_DECIMAL_PATTERN);

      try {
        return format.format(new Double(numberAsString));
      } catch (NumberFormatException numberFormatException) {
        return NOT_A_NUMBER_PREFIX + " (" + numberAsString + ")";
      }
    }
    return numberAsString;
View Full Code Here

        else {
            throw new IllegalStateException("The formatter is not an instance of DefaultFormatter.");
        }

        if (formatter instanceof InternationalFormatter) {
            Format f = ((InternationalFormatter) formatter).getFormat();
            if (f instanceof DateFormat) {
                _format = ((DateFormat) f);
            }
        }
View Full Code Here

   * @param element
   * @return The formatted value.
   */
  public Object getValue(final ExpressionRuntime runtime, final ReportElement element)
  {
    final Format f = getFormatter();
    if (f == null)
    {
      return getNullValue();
    }

    final DataSource ds = getDataSource();
    if (ds == null)
    {
      return getNullValue();
    }

    final Object o = ds.getValue(runtime, element);
    if (o == null)
    {
      return getNullValue();
    }

    if (cachedResult != null && (cachedFormat != f) &&
        ObjectUtilities.equal(cachedValue, o))
    {
      return cachedResult;
    }

    try
    {
      cachedResult = f.format(o);
    }
    catch (IllegalArgumentException e)
    {
      cachedResult = getNullValue();
    }
View Full Code Here

   * @param element
   * @return The formatted value.
   */
  public Object getValue(final ExpressionRuntime runtime, final ReportElement element)
  {
    final Format f = getFormatter();
    if (f == null)
    {
      return getNullValue();
    }

    final DataSource ds = getDataSource();
    if (ds == null)
    {
      return getNullValue();
    }

    final Object o = ds.getValue(runtime, element);
    if (o == null)
    {
      return getNullValue();
    }

    if (isValidOutput(o))
    {
      return o;
    }

    try
    {
      return f.parseObject(String.valueOf(o));
    }
    catch (ParseException e)
    {
      return null;
    }
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

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.