format.format(options)
Method Description |
Formats a value from the raw value to its appropriate preference format.
Note:
This method is overloaded when you format a |
Returns |
If a datetime or datetimetz value is specified, the string in date format is returned in the user’s local app time zone.
Note:
If an invalid value is given, the original value passed to
Note:
For client scripts, the string returned is based on the user’s system time. For server scripts, the string returned is based on the current time in the Pacific Time Zone. Daylight Savings Time does apply. |
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
This method is overloaded when you format a datetime
or datetimetz
value.
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
Date | string | number |
required |
The input data to format. |
2015.2 |
|
string |
required |
The field type (for example, Set using the format.Type enum. |
2015.2 |
The table below applies to datetime and datetimetz values only.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
Date |
required |
The Date Object being converted into a string |
2015.2 |
|
string |
required |
The field type (either Set using the format.Type enum. |
2015.2 |
|
enum | number |
optional |
The time zone specified for the returned string. Set using the format.Timezone enum or key. If a time zone is not specified, the time zone is set based on user preference. If the time zone is invalid, the time zone is set to GMT. |
2015.2 |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/format Module Script Samples.
// Add additional code
...
function(format){
function formatToString() {
// Assume number format is 1.000.000,00 and negative format is (100)
var rawNum2 = -44444.44
return format.format({value:rawNum2, type: format.Type.FLOAT})
}
var formattedNum2 = formatToString(); // "44.444,44" -- a string
...
// Add additional code