Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.gwtext.client.util
Class Format

    java.lang.Object
      com.gwtext.client.util.Format

    public class Format

extends java.lang.Object

Reusable data formatting functions.

Constructor Summary
`Format()`

Method Summary
`static java.lang.String` | `date(java.lang.String value)` Parse a value into a formatted date using the specified format pattern.
`static java.lang.String` | `date(java.lang.String value, java.lang.String format)` Parse a value into a formatted date using the specified format pattern.
`static java.lang.String` | `ellipsis(java.lang.String value, int length)` Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length.
`static java.lang.String` | `fileSize(long size)` Simple format for a file size (xxx bytes, xxx KB, xxx MB).
`static java.lang.String` | `format(java.lang.String format, int value)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, int value1, int value2)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, int value1, int value2, int value3)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String[] values)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2, java.lang.String value3)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5, java.lang.String value6)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `format(java.lang.String format, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5, java.lang.String value6, java.lang.String value7)` Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.
`static java.lang.String` | `htmlDecode(java.lang.String value)` Convert certain characters (&, <, >, and ') from their HTML character equivalents.
`static java.lang.String` | `htmlEncode(java.lang.String value)` Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
`static java.lang.String` | `leftPad(java.lang.String string, int size)` Pads the left side of a string with a specified character.
`static java.lang.String` | `leftPad(java.lang.String string, int size, java.lang.String character)` Pads the left side of a string with a specified character.
`static java.lang.String` | `stripScripts(java.lang.String text)` Strips all script tags.
`static java.lang.String` | `stripTags(java.lang.String value)` Strips all HTML tags.
`static java.lang.String` | `usMoney(double value)` Format a number as US currency.
`static java.lang.String` | `usMoney(java.lang.String value)` Format a number as US currency.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Format

    public Format()

Method Detail

### date

    public static java.lang.String date(java.lang.String value)

  Parse a value into a formatted date using the specified format pattern. Format defaults to 'm/d/Y'.

  Parameters:
    `value` - the date string
  Returns:
    the formatted date string

### date

    public static java.lang.String date(java.lang.String value,
                                        java.lang.String format)

  Parse a value into a formatted date using the specified format pattern.

  Parameters:
    `value` - the value to format
    `format` - Any valid date format string (defaults to 'm/d/Y')
  Returns:
    the formatted date string

### ellipsis

    public static java.lang.String ellipsis(java.lang.String value,
                                            int length)

  Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length.

  Parameters:
    `value` - the string to truncate
    `length` - the maximum length to allow before truncating
  Returns:
    the converted text

### htmlDecode

    public static java.lang.String htmlDecode(java.lang.String value)

  Convert certain characters (&, <, >, and ') from their HTML character equivalents.

  Parameters:
    `value` - the string to decode
  Returns:
    the decoded text

### htmlEncode

    public static java.lang.String htmlEncode(java.lang.String value)

  Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.

  Parameters:
    `value` - the string to encode
  Returns:
    the encoded text

### stripTags

    public static java.lang.String stripTags(java.lang.String value)

  Strips all HTML tags.

  Parameters:
    `value` - the text from which to strip tags
  Returns:
    the stripped text

### stripScripts

    public static java.lang.String stripScripts(java.lang.String text)

  Strips all script tags.

  Parameters:
    `text` - the text from which to strip script tags
  Returns:
    the stripped text

### fileSize

    public static java.lang.String fileSize(long size)

  Simple format for a file size (xxx bytes, xxx KB, xxx MB).

  Parameters:
    `size` - the numeric value to format
  Returns:
    the formatted file size

### usMoney

    public static java.lang.String usMoney(java.lang.String value)

  Format a number as US currency.

  Parameters:
    `value` - the value value to format
  Returns:
    the formatted currency string

### usMoney

    public static java.lang.String usMoney(double value)

  Format a number as US currency.

  Parameters:
    `value` - the numeric value to format
  Returns:
    the formatted currency string

### format

    public static java.lang.String format(java.lang.String format,
                                          int value)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value` - the value to replace token {0}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value` - the value to replace token {0}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String[] values)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `values` - the value to replace token {0}, {1}, ...
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          int value1,
                                          int value2)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          int value1,
                                          int value2,
                                          int value3)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2,
                                          java.lang.String value3)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2,
                                          java.lang.String value3,
                                          java.lang.String value4)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
    `value4` - the value to replace token {3}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2,
                                          java.lang.String value3,
                                          java.lang.String value4,
                                          java.lang.String value5)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
    `value4` - the value to replace token {3}
    `value5` - the value to replace token {4}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2,
                                          java.lang.String value3,
                                          java.lang.String value4,
                                          java.lang.String value5,
                                          java.lang.String value6)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
    `value4` - the value to replace token {3}
    `value5` - the value to replace token {4}
    `value6` - the value to replace token {5}
  Returns:
    the formatted string

### format

    public static java.lang.String format(java.lang.String format,
                                          java.lang.String value1,
                                          java.lang.String value2,
                                          java.lang.String value3,
                                          java.lang.String value4,
                                          java.lang.String value5,
                                          java.lang.String value6,
                                          java.lang.String value7)

  Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.

  Parameters:
    `format` - the tokenized string to be formatted
    `value1` - the value to replace token {0}
    `value2` - the value to replace token {1}
    `value3` - the value to replace token {2}
    `value4` - the value to replace token {3}
    `value5` - the value to replace token {4}
    `value6` - the value to replace token {5}
    `value7` - the value to replace token {6}
  Returns:
    the formatted string

### leftPad

    public static java.lang.String leftPad(java.lang.String string,
                                           int size)

  Pads the left side of a string with a specified character. This is especially useful for normalizing number and date strings.

        String val = Format.leftPad("123", 5, "0");
        //val now containts the String "00123"

  Parameters:
    `string` - the original string
    `size` - the total length of the output string
  Returns:
    the padded string

### leftPad

    public static java.lang.String leftPad(java.lang.String string,
                                           int size,
                                           java.lang.String character)

  Pads the left side of a string with a specified character. This is especially useful for normalizing number and date strings.

        String val = Format.leftPad("123", 5, "0");
        //val now containts the String "00123"

  Parameters:
    `string` - the original string
    `size` - the total length of the output string
    `character` - he character with which to pad the original string (defaults to empty string " ")
  Returns:
    the padded string

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD