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

## [](#tolocaldatetime1)toLocalDateTime(str: String, formatters: Array<Formatter>): LocalDateTime

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

_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>LocalDateTime</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>LocalDateTime</code>​ 値に対して使用する書式設定の​<code>配列</code>​。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

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

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
import * from dw::Runtime
output application/dw
---
{
  a: toLocalDateTime("2003-10-01 23:57:59", [{format: "uuuu/MM/dd HH:mm:ss"}, {format: "uuuu-MM-dd HH:mm:ss"}]),
  b: try(() -> toLocalDateTime("2003-10-01 23:57:59", [{format: "uuuu/MM/dd HH:mm:ss"}])).error.message
}
```

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

```DataWeave
{
  a: |2003-10-01T23:57:59| as LocalDateTime {format: "uuuu-MM-dd HH:mm:ss"},
  b: "Could not find a valid formatter for '2003-10-01 23:57:59'"
}
```

## [](#tolocaldatetime2)toLocalDateTime(str: String, format: String | Null = null, locale: String | Null = null): LocalDateTime

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

_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>LocalDateTime</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>LocalDateTime</code>​ 値に対して使用する書式設定。
           ​<code>null</code>​ 値は ​<code>LocalDateTime</code>​ 値に対して無効です。
           このパラメーターでは、ISO-8601 に基づいた Java 文字パターンを受け入れます。​<code>2011-12-03T10:15:30.000000</code>​ などの ​<code>LocalDateTime</code>​ 値の形式は ​<code>uuuu-MM-dd HH:mm:ss</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)例

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

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
  a: toLocalDateTime("2015-10-01T23:57:59"),
  b: toLocalDateTime("2003-10-01 23:57:59","uuuu-MM-dd HH:mm:ss")
}
```

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

```DataWeave
{
  a: |2015-10-01T23:57:59|,
  b: |2003-10-01T23:57:59| as LocalDateTime {format: "uuuu-MM-dd HH:mm:ss"}
}
```