---
schema_version: "1"
id: f71b1c08bbc349e627f53c9b441e1bcfbefd715be184d116c4b137ec7f5702be
title: hours
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-periods-functions-hours.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-periods-functions-hours
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9db59b876db8cf66f4f95e203e7436325e44d526ab8fa540e5457a9ae34e375a
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
# hours

## [](#hours1)hours(nHours: Number): Period

指定された時間数から Period (期間) 値を作成します。

この関数では、​`duration`​ 関数を入力値に適用します。

_DataWeave バージョン 2.4.0 で導入されました。_​

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>nHours</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">整数または小数としての時間数。
             正または負の数値が有効です。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`hours`​ の動作を示します。 DateTime (日時) 値および LocalTime (ローカル時刻) 値に対して時間数を加算および減算します。 また、小数値 ​`4.555`​ を Period (期間) 形式 (​`PT4H33M18S`​) に、整数 ​`4`​ を Period (期間) 形式 (​`PT4H`​) にも変換します。 `hours(-1) + hours(2)`​ では秒数が返されます。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
import * from dw::core::Periods
output application/json
---
{
   nextHour: |2020-10-05T20:22:34.385Z| + hours(1),
   previousHour: |2020-10-05T20:22:34.385Z| - hours(1),
   threeHoursLater: |20:22| + hours(3),
   addDecimalInput: |20:22| + hours(3.5),
   decimalInputAsPeriod : hours(4.555),
   fourHourPeriod : hours(4),
   addNegativeValue: hours(-1) + hours(2)
}
```

#### [](#出力)出力

```Json
{
   "nextHour": "2020-10-05T21:22:34.385Z",
   "previousHour": "2020-10-05T19:22:34.385Z",
   "threeHoursLater": "23:22:00",
   "addDecimalInput": "23:52:00",
   "decimalInputAsPeriod": "PT4H33M18S",
   "fourHourPeriod": "PT4H",
   "addNegativeValue": 3600
}
```