---
schema_version: "1"
id: fd0eab32318d47ed34aa802e627e5aaf6b177c7b3bd4957a0152439cb7b11f4b
title: toTime
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-coercions-functions-totime.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-coercions-functions-totime
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2988fbdaaff8a299beb451139b5d6ede570a33572f4f7f5ff944ecc211164ba3
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# toTime

## [](#totime1)toTime(str: String, formatters: Array<Formatter>): Time

変換する特定の値に一致する最初の​`フォーマッター`​を使用して、​`String`​ 値を ​`Time`​ 値に変換します。

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

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

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<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>str</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Time</code>​ 値に変換する ​<code>String</code>​ 値。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>formatters</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Array&lt;Formatter&gt;</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Time</code>​ 値に対して使用する書式設定の​<code>配列</code>​。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`toTime`​ の動作を示します。 `application/dw`​ 形式の出力が生成されます。

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
import * from dw::Runtime
output application/dw
---
{
  a: toTime("13:44:12.283-08:00", [{format: "HH:mm:ss.xxx"}, {format: "HH:mm:ss.nxxx"}]),
  b: try(() -> toTime("13:44:12.283-08:00", [{format: "HH:mm:ss.xxx"}]).error.message
}
```

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

```DataWeave
{
  a: |13:44:12.000000283-08:00| as Time {format: "HH:mm:ss.nxxx"},
  b: "Could not find a valid formatter for '13:44:12.283-08:00'"
}
```

## [](#totime2)toTime(str: String, format: String | Null = null, locale: String | Null = null): Time

`String`​ 値を ​`Time`​ 値に変換して、形式とロケールを受け入れます。

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

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

<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>str</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Time</code>​ 値に変換する ​<code>String</code>​ 値。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>format</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Time</code>​ 値に対して使用する書式設定。
           ​<code>null</code>​ 値は ​<code>Time</code>​ 値に対して無効です。
           このパラメーターでは、ISO-8601 に基づいた Java 文字パターンを受け入れます。​<code>10:15:30.000000</code>​ などの ​<code>Time</code>​ 値の形式は ​<code>HH:mm:ss.nxxx</code>​ となります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>locale</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">使用する省略可能な ISO 3166 国コード (​<code>US</code>​、​<code>AR</code>​、​<code>ES</code>​ など)。​<code>null</code>​ または欠落値では JVM のデフォルトが使用されます。</p></td>
</tr>
</tbody>
</table>

### [](#例-2)例

次の例では、さまざまな入力での ​`toTime`​ の動作を示します。 `application/dw`​ 形式の出力が生成されます。

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
   a: toTime("23:57:59Z"),
   b: toTime("13:44:12.283-08:00","HH:mm:ss.nxxx")
}
```

#### [](#出力-2)出力

```DataWeave
{
  a: |23:57:59Z|,
  b: |13:44:12.000000283-08:00| as Time {format: "HH:mm:ss.nxxx"}
}
```