---
schema_version: "1"
id: cd599b395c00c13345241beb6e5d543d60b15df407cf99a1b94ab33948cb0fc9
title: hours
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-periods-functions-hours.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-periods-functions-hours
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c8b99b10b2da83b4567f07384bb1f3435cf374a23f35f52e57b7125f98fb7eb5
description: MuleSoft Documentation Site
release: "2.8"
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
}
```