---
schema_version: "1"
id: 54c7668640e2d3179c38e45e27c63baa2787a0393d42cf87b279d4a3643755b7
title: toDateOrNull
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-coercions-functions-todateornull.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-coercions-functions-todateornull
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 09238acbeec4145ccedff18d75cde91ec42d289439295594719ec967d58b1f43
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# toDateOrNull

## [](#todateornull1)toDateOrNull(str: String, formatters: Array<Formatter>): Date | Null

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

指定した値に一致する​`フォーマッター`​がない場合、関数は ​`null`​ 値を返します。

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

### [](#例)例

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

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
  a: toDateOrNull("2023-28-03", [{format: "yyyy/MM/dd"}, {format: "yyyy-dd-MM", locale: "en_US"}]),
  b: toDateOrNull("2023-28-03", [{format: "yyyy/MM/dd"}])
}
```

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

```DataWeave
{
  a: |2023-03-28| as Date {format: "yyyy-dd-MM", locale: "en_US"},
  b: null
}
```