ToChar
Emulates Oracle's TO_CHAR function.
| Methods |
| static String[] |
getDateNames(int names)
Get the date (month / weekday / ...) names.
|
| static String[] |
getDateNames(int names)
Get the date (month / weekday / ...) names.
Parameters:
names - the field
Returns:
the names
|
| static String |
toChar(BigDecimal number, String format, String nlsParam)
Emulates Oracle's TO_CHAR(number) function.
|
| static String |
toChar(BigDecimal number, String format, String nlsParam)
Emulates Oracle's TO_CHAR(number) function.
| Input |
Output |
Closest {@link DecimalFormat} Equivalent |
| , |
Grouping separator. |
, |
| . |
Decimal separator. |
. |
| $ |
Leading dollar sign. |
$ |
| 0 |
Leading or trailing zeroes. |
0 |
| 9 |
Digit. |
# |
| B |
Blanks integer part of a fixed point number less than 1. |
# |
| C |
ISO currency symbol. |
¤ |
| D |
Local decimal separator. |
. |
| EEEE |
Returns a value in scientific notation. |
E |
| FM |
Returns values with no leading or trailing spaces. |
None. |
| G |
Local grouping separator. |
, |
| L |
Local currency symbol. |
¤ |
| MI |
Negative values get trailing minus sign,
positive get trailing space. |
- |
| PR |
Negative values get enclosing angle brackets,
positive get spaces. |
None. |
| RN |
Returns values in Roman numerals. |
None. |
| S |
Returns values with leading/trailing +/- signs. |
None. |
| TM |
Returns smallest number of characters possible. |
None. |
| U |
Returns the dual currency symbol. |
None. |
| V |
Returns a value multiplied by 10^n. |
None. |
| X |
Hex value. |
None. |
See also TO_CHAR(number) and number format models
in the Oracle documentation.
Parameters:
number - the number to format
format - the format pattern to use (if any)
nlsParam - the NLS parameter (if any)
Returns:
the formatted number
|
| static String |
toCharDateTime(Value value, String format, String nlsParam)
Emulates Oracle's TO_CHAR(datetime) function.
|
| static String |
toCharDateTime(Value value, String format, String nlsParam)
Emulates Oracle's TO_CHAR(datetime) function.
| Input |
Output |
Closest {@link SimpleDateFormat} Equivalent |
| - / , . ; : "text" |
Reproduced verbatim. |
'text' |
| A.D. AD B.C. BC |
Era designator, with or without periods. |
G |
| A.M. AM P.M. PM |
AM/PM marker. |
a |
| CC SCC |
Century. |
None. |
| D |
Day of week. |
u |
| DAY |
Name of day. |
EEEE |
| DY |
Abbreviated day name. |
EEE |
| DD |
Day of month. |
d |
| DDD |
Day of year. |
D |
| DL |
Long date format. |
EEEE, MMMM d, yyyy |
| DS |
Short date format. |
MM/dd/yyyy |
| E |
Abbreviated era name (Japanese, Chinese, Thai) |
None. |
| EE |
Full era name (Japanese, Chinese, Thai) |
None. |
| FF[1-9] |
Fractional seconds. |
S |
| FM |
Returns values with no leading or trailing spaces. |
None. |
| FX |
Requires exact matches between character data and format model. |
None. |
| HH HH12 |
Hour in AM/PM (1-12). |
hh |
| HH24 |
Hour in day (0-23). |
HH |
| IW |
Week in year. |
w |
| WW |
Week in year. |
w |
| W |
Week in month. |
W |
| IYYY IYY IY I |
Last 4/3/2/1 digit(s) of ISO year. |
yyyy yyy yy y |
| RRRR RR |
Last 4/2 digits of year. |
yyyy yy |
| Y,YYY |
Year with comma. |
None. |
| YEAR SYEAR |
Year spelled out (S prefixes BC years with minus sign). |
None. |
| YYYY SYYYY |
4-digit year (S prefixes BC years with minus sign). |
yyyy |
| YYY YY Y |
Last 3/2/1 digit(s) of year. |
yyy yy y |
| J |
Julian day (number of days since January 1, 4712 BC). |
None. |
| MI |
Minute in hour. |
mm |
| MM |
Month in year. |
MM |
| MON |
Abbreviated name of month. |
MMM |
| MONTH |
Name of month, padded with spaces. |
MMMM |
| RM |
Roman numeral month. |
None. |
| Q |
Quarter of year. |
None. |
| SS |
Seconds in minute. |
ss |
| SSSSS |
Seconds in day. |
None. |
| TS |
Short time format. |
h:mm:ss aa |
| TZD |
Daylight savings time zone abbreviation. |
z |
| TZR |
Time zone region information. |
zzzz |
| X |
Local radix character. |
None. |
See also TO_CHAR(datetime) and datetime format models
in the Oracle documentation.
Parameters:
value - the date-time value to format
format - the format pattern to use (if any)
nlsParam - the NLS parameter (if any)
Returns:
the formatted timestamp
|
JULIAN_EPOCH
= -2440588
The beginning of the Julian calendar.
MONTHS
= 0
The month field.
SHORT_MONTHS
= 1
The month field (short form).
WEEKDAYS
= 2
The weekday field.
SHORT_WEEKDAYS
= 3
The weekday field (short form).
AM_PM
= 4
The AM / PM field.
|