Properties Methods Events Direct Link

# Class Ext.util.Format

Package: | Ext.util
Defined In: | Format.js
Class: | Format
Extends: | Object

Reusable data formatting functions
This class is a singleton and cannot be created directly.

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---

capitalize( `String value` ) : String
Converts the first character only of a string to upper case
Converts the first character only of a string to upper case
Parameters:

- `value` : String
  The text to convert

Returns:

- `String`
  The converted text

Format

date( `Mixed value`, [`String format`] ) : String
Parse a value into a formatted date using the specified format pattern.
Parse a value into a formatted date using the specified format pattern.
Parameters:

- `value` : Mixed
  The value to format
- `format` : String
  (optional) Any valid date format string (defaults to 'm/d/Y')

Returns:

- `String`
  The formatted date string

Format

dateRenderer( `String format` ) : Function
Returns a date rendering function that can be reused to apply a date format multiple times efficiently
Returns a date rendering function that can be reused to apply a date format multiple times efficiently
Parameters:

- `format` : String
  Any valid date format string

Returns:

- `Function`
  The date formatting function

Format

defaultValue( `Mixed value`, `String defaultValue` ) : String
Checks a reference and converts it to the default value if it's empty
Checks a reference and converts it to the default value if it's empty
Parameters:

- `value` : Mixed
  Reference to check
- `defaultValue` : String
  The value to insert of it's undefined (defaults to "")

Returns:

- `String`

Format

ellipsis( `String value`, `Number length` ) : String
Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length
Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length
Parameters:

- `value` : String
  The string to truncate
- `length` : Number
  The maximum length to allow before truncating

Returns:

- `String`
  The converted text

Format

fileSize( `Number/String size` ) : String
Simple format for a file size (xxx bytes, xxx KB, xxx MB)
Simple format for a file size (xxx bytes, xxx KB, xxx MB)
Parameters:

- `size` : Number/String
  The numeric value to format

Returns:

- `String`
  The formatted file size

Format

htmlDecode( `String value` ) : String
Convert certain characters (&, <, >, and ') from their HTML character equivalents.
Convert certain characters (&, <, >, and ') from their HTML character equivalents.
Parameters:

- `value` : String
  The string to decode

Returns:

- `String`
  The decoded text

Format

htmlEncode( `String value` ) : String
Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
Parameters:

- `value` : String
  The string to encode

Returns:

- `String`
  The encoded text

Format

lowercase( `String value` ) : String
Converts a string to all lower case letters
Converts a string to all lower case letters
Parameters:

- `value` : String
  The text to convert

Returns:

- `String`
  The converted text

Format

stripScripts( `Mixed value` ) : String
Strips all script tags
Strips all script tags
Parameters:

- `value` : Mixed
  The text from which to strip script tags

Returns:

- `String`
  The stripped text

Format

stripTags( `Mixed value` ) : String
Strips all HTML tags
Strips all HTML tags
Parameters:

- `value` : Mixed
  The text from which to strip tags

Returns:

- `String`
  The stripped text

Format

substr( `String value`, `Number start`, `Number length` ) : String
Returns a substring from within an original string
Returns a substring from within an original string
Parameters:

- `value` : String
  The original text
- `start` : Number
  The start index of the substring
- `length` : Number
  The length of the substring

Returns:

- `String`
  The substring

Format

trim( `String value` ) : String
Trims any whitespace from either side of a string
Trims any whitespace from either side of a string
Parameters:

- `value` : String
  The text to trim

Returns:

- `String`
  The trimmed text

Format

undef( `Mixed value` ) : Mixed
Checks a reference and converts it to empty string if it is undefined
Checks a reference and converts it to empty string if it is undefined
Parameters:

- `value` : Mixed
  Reference to check

Returns:

- `Mixed`
  Empty string if converted, otherwise the original value

Format

uppercase( `String value` ) : String
Converts a string to all upper case letters
Converts a string to all upper case letters
Parameters:

- `value` : String
  The text to convert

Returns:

- `String`
  The converted text

Format

usMoney( `Number/String value` ) : String
Format a number as US currency
Format a number as US currency
Parameters:

- `value` : Number/String
  The numeric value to format

Returns:

- `String`
  The formatted currency string

Format

## Public Events

This class has no public events.