forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: chenxiaoxiong <chenxiaoxiong@huawei.com> Co-committed-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
140 lines
16 KiB
HTML
140 lines
16 KiB
HTML
<a name="dataartsstudio_01_0500"></a><a name="dataartsstudio_01_0500"></a>
|
|
|
|
<h1 class="topictitle1">DateUtil Embedded Objects</h1>
|
|
<div id="body8662426"><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p157761619111518">A DateUtil embedded object provides methods of formatting time and calculating time.</p>
|
|
<div class="section" id="dataartsstudio_01_0500__en-us_topic_0132846499_section18841149151713"><h4 class="sectiontitle">Methods</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_01_0500__en-us_topic_0132846499_table662281718176" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Method description</caption><thead align="left"><tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row46221117141716"><th align="left" class="cellrowborder" valign="top" width="25.929999999999996%" id="mcps1.3.2.2.2.4.1.1"><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p462211713178">Method</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="32.99%" id="mcps1.3.2.2.2.4.1.2"><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p76223174172">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="41.08%" id="mcps1.3.2.2.2.4.1.3"><p id="dataartsstudio_01_0500__p202901522102016">Example</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row1362211771712"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1862213172179">String format(Date date, String pattern)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p76225177173">Formats Date to character strings according to the specified pattern.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p755783092217">Convert the planned job scheduling time to the millisecond format.</p>
|
|
<p id="dataartsstudio_01_0500__p32631945718">#{DateUtil.format(Job.planTime,"yyyy-MM-dd HH:mm:ss:SSS")}</p>
|
|
<p id="dataartsstudio_01_0500__p172789461311">Subtracts one day from the planned job scheduling time and convert the time to the week format.</p>
|
|
<ul id="dataartsstudio_01_0500__ul1227844620120"><li id="dataartsstudio_01_0500__li1227811463113">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyyw")}<p id="dataartsstudio_01_0500__p202785461315"><a name="dataartsstudio_01_0500__li1227811463113"></a><a name="li1227811463113"></a>If <strong id="dataartsstudio_01_0500__b896615971719">Job.planTime</strong> is January 7, 2024, value <strong id="dataartsstudio_01_0500__b1085345101718">20241</strong> is returned.</p>
|
|
</li></ul>
|
|
<ul id="dataartsstudio_01_0500__ul02781346716"><li id="dataartsstudio_01_0500__li627818461217">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyyww")}<p id="dataartsstudio_01_0500__p18278246116"><a name="dataartsstudio_01_0500__li627818461217"></a><a name="li627818461217"></a>If <strong id="dataartsstudio_01_0500__b957128131814">Job.planTime</strong> is January 7, 2024, value <strong id="dataartsstudio_01_0500__b16571208111810">202401</strong> is returned.</p>
|
|
</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row106221717141711"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p962251761716">Date addMonths(Date date, int amount)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1962281716170">After the specified number of months is added to Date, the new Date object is returned. The amount can be a negative number.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p20847034143616">Subtract one month from the planned job scheduling time and convert the time to the month format.</p>
|
|
<p id="dataartsstudio_01_0500__p0848153433619">#{DateUtil.format(DateUtil.addMonths(Job.planTime,-1),"yyyy-MM")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row962291716173"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p36229173170">Date addDays(Date date, int amount)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p762291715173">After the specified number of days is added to Date, the new Date object is returned. The amount can be a negative number.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p112741632133810">Subtracts one day from the planned job scheduling time and convert the time to the yyyy-MM-dd format.</p>
|
|
<p id="dataartsstudio_01_0500__p72744328384">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyy-MM-dd")}</p>
|
|
<p id="dataartsstudio_01_0500__p332565611482">Subtracts one day from the planned job scheduling time and convert the time to the week format. (y: within one year)</p>
|
|
<ul id="dataartsstudio_01_0500__ul9325165694812"><li id="dataartsstudio_01_0500__li8325145610480">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyyw")}<p id="dataartsstudio_01_0500__p3325175624818"><a name="dataartsstudio_01_0500__li8325145610480"></a><a name="li8325145610480"></a>If <strong id="dataartsstudio_01_0500__b1012845182010">Job.planTime</strong> is January 7, 2024, value <strong id="dataartsstudio_01_0500__b61335511209">20241</strong> is returned.</p>
|
|
</li></ul>
|
|
<ul id="dataartsstudio_01_0500__ul6325115674818"><li id="dataartsstudio_01_0500__li9325256104818">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyyww")}<p id="dataartsstudio_01_0500__p1199913296718"><a name="dataartsstudio_01_0500__li9325256104818"></a><a name="li9325256104818"></a>If <strong id="dataartsstudio_01_0500__b97421139191117">Job.planTime</strong> is January 7, 2024, value <strong id="dataartsstudio_01_0500__b1074314390115">202401</strong> is returned.</p>
|
|
</li></ul>
|
|
<p id="dataartsstudio_01_0500__p650311387718">Subtracts one day from the planned job scheduling time and convert the time to the week format. (Y: across years)</p>
|
|
<ul id="dataartsstudio_01_0500__ul572219162108"><li id="dataartsstudio_01_0500__li9722151651011">#{DateUtil.format(DateUtil.addDays(Job.planTime,-7),"YYYYww")}<p id="dataartsstudio_01_0500__p1772271615106"><a name="dataartsstudio_01_0500__li9722151651011"></a><a name="li9722151651011"></a>If <strong id="dataartsstudio_01_0500__b8278487126">Job.planTime</strong> is January 7, 2024, value <strong id="dataartsstudio_01_0500__b1127816851217">202401</strong> is returned.</p>
|
|
<div class="note" id="dataartsstudio_01_0500__note111211115121414"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="dataartsstudio_01_0500__p31217157145">The differences between yyyy and YYYY are as follows:</p>
|
|
<ul id="dataartsstudio_01_0500__ul62921325208"><li id="dataartsstudio_01_0500__li13292832132017">YYYY indicates the week year. It can correctly process the number of weeks across years.</li><li id="dataartsstudio_01_0500__li14292123210205">yyyy indicates the calendar year, which may cause an inaccurate number of weeks across years.</li><li id="dataartsstudio_01_0500__li1791033512208">Therefore, YYYY is used for processing cross-year services. Except that, yyyy should be used.</li><li id="dataartsstudio_01_0500__li1073191115222">Currently, the calendar week is from Sunday to Saturday, rather than from Monday to Sunday.</li></ul>
|
|
</div></div>
|
|
</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row4622317151718"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p16226172179">Date addHours(Date date, int amount)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p206228179177">After the specified number of hours is added to Date, the new Date object is returned. The amount can be a negative number.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p203554264424">Subtract one hour from the planned job scheduling time and convert the time to the hour format.</p>
|
|
<p id="dataartsstudio_01_0500__p2355122674213">#{DateUtil.format(DateUtil.addHours(Job.planTime,-1),"yyyy-MM-dd HH")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row2062217172171"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p262271717175">Date addMinutes(Date date, int amount)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p162281781713">After the specified number of minutes is added to Date, the new Date object is returned. The amount can be a negative number.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p5505524616">Subtract one minute from the planned job scheduling time and convert the time to the minute format.</p>
|
|
<p id="dataartsstudio_01_0500__p95011519468">#{DateUtil.format(DateUtil.addMinutes(Job.planTime,-1),"yyyy-MM-dd HH:mm")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row186221917161712"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1762211718175">int getDay(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1862281719176">Obtains the day from the date. For example, if the date is 2018-09-14, 14 is returned.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p1547114674711">Obtain the day from the job scheduling plan.</p>
|
|
<p id="dataartsstudio_01_0500__p5471176134713">#{DateUtil.getDay(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row152311126192317"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p17246226152319">int getMonth(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1624632642314">Obtains the month from the date. For example, if the date is 2018-09-14, 9 is returned.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p186741553184820">Obtain the month from the date.</p>
|
|
<p id="dataartsstudio_01_0500__p6674155354815">#{DateUtil.getMonth(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__row8955181016247"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__p295671017249">int getQuarter(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__p14956101062411">Obtains the quarter from the date. For example, if the date is 2018-09-14, 3 is returned.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p63141640172610">Obtain the quarter from the date.</p>
|
|
<p id="dataartsstudio_01_0500__p331534017262">#{DateUtil.getQuarter(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row136221917161712"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1622131710172">int getYear(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1862214170171">Obtains the year from the date. For example, if the date is 2018-09-14, 2018 is returned.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p442312346493">Obtain the year from the date.</p>
|
|
<p id="dataartsstudio_01_0500__p15424113419492">#{DateUtil.getYear(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row453518713244"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p453537132411">Date now()</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p053597152414">Returns the current time.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p10221141110521">Return the current time accurate to second.</p>
|
|
<p id="dataartsstudio_01_0500__p15221171115211">#{DateUtil.format(DateUtil.now(),"yyyy-MM-dd HH:mm:ss")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row08793413247"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p5879104152420">long getTime(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p987912482412">Converts a time of the date type to one of the long type.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p4501202383610">Convert the planned job scheduling time to a timestamp.</p>
|
|
<p id="dataartsstudio_01_0500__p799171118359">#{DateUtil.getTime(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_0500__en-us_topic_0132846499_row95165818237"><td class="cellrowborder" valign="top" width="25.929999999999996%" headers="mcps1.3.2.2.2.4.1.1 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p45155892313">Date parseDate(String str, String pattern)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.99%" headers="mcps1.3.2.2.2.4.1.2 "><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p1251185852320">Converts the character string to the date by pattern. The pattern is the date and time mode. For details, see <a href="dataartsstudio_01_0496.html">Date and Time Mode</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="41.08%" headers="mcps1.3.2.2.2.4.1.3 "><p id="dataartsstudio_01_0500__p10446155573814">Convert the job start time string to a time accurate to second.</p>
|
|
<p id="dataartsstudio_01_0500__p1672601363712">#{DateUtil.parseDate(Job.getPlanTime("yyyy-MM-dd HH:mm:ss:SSS"),"yyyy-MM-dd HH:mm:ss")}</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dataartsstudio_01_0500__en-us_topic_0132846499_section4812102915281"><h4 class="sectiontitle"><strong id="dataartsstudio_01_0500__en-us_topic_0132846499_b387132213711">Example</strong></h4><p id="dataartsstudio_01_0500__en-us_topic_0132846499_p168761531192818">The previous day of the job scheduling plan time is used as the subdirectory name to generate an OBS path. The EL expression is as follows:</p>
|
|
<pre class="screen" id="dataartsstudio_01_0500__en-us_topic_0132846499_screen1332128183113">#{"obs://test/"+DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyy-MM-dd")}</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dataartsstudio_01_0493.html">EL Expression Reference</a></div>
|
|
</div>
|
|
</div>
|
|
|