tamaki.mes.utils.formatDate
Description
Formats a date value into a string using a Java SimpleDateFormat pattern. The value may be either
milliseconds (int/long) or a java.util.Date. The timezone is determined by the explicit timezone
argument; if a component self is supplied, the timezone is taken from the session props
(self.session.props.timeZoneId). When neither yields a timezone, it falls back to Etc/UTC.
Raises a TypeError if value is neither a number nor a Date.
Syntax
tamaki.mes.utils.formatDate(value, self=None, timezone="Etc/UTC", format="yyyy-MM-dd HH:mm:ss")
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
value | Number or Date | False | The date/time value to format: milliseconds (int/long) or a java.util.Date. |
self | Object | True | The component self, used to infer the session timezone when timezone is not provided. Defaults to None. |
timezone | String | True | An explicit timezone ID (for example "UTC", "America/Toronto"). Defaults to "Etc/UTC". |
format | String | True | A Java SimpleDateFormat pattern. Defaults to "yyyy-MM-dd HH:mm:ss". |
Returns
A String containing the formatted date.
Code Examples
# In a binding script transform: format an epoch-millis or Date value using the session timezone
return tamaki.mes.utils.formatDate(value, self)
# With an explicit timezone and output pattern
formatted = tamaki.mes.utils.formatDate(1716309180000, timezone="America/Toronto", format="yyyy-MM-dd")