---
schema_version: "1"
id: 6a692c4395f1f99ecf9beeb977cb2b50d3c11ac6fb826ff0be0bc69aaba2237a
title: toDateTime
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.7/dw-coercions-functions-todatetime.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.7/dw-coercions-functions-todatetime
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1e1fef12cc5b42d659507c17d925e72e13ebc7c99f29ddf8f679c55c48c9a088
description: MuleSoft Documentation Site
release: "2.7"
latest: false
---
# toDateTime

## [](#todatetime1)toDateTime(number: Number, unit: MillisOrSecs | Null = null): DateTime

`milliseconds`​ または ​`seconds`​ を単位として使用して ​`Number`​ 値を ​`DateTime`​ 値に変換します。

_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>number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DateTime</code>​ 値に変換する ​<code>Number</code>​ 値。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unit</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">変換に使用する単位: <code>"milliseconds"</code>​ または ​<code>"seconds"</code>​。​<code>unit</code>​ 項目の ​<code>null</code>​ 値のデフォルトは ​<code>"seconds"</code>​ です。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

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

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

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
    fromEpoch: toDateTime(1443743879),
    fromMillis: toDateTime(1443743879000, "milliseconds")
}
```

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

```DataWeave
{
  fromEpoch: |2015-10-01T23:57:59Z|,
  fromMillis: |2015-10-01T23:57:59Z| as DateTime {unit: "milliseconds"}
}
```

## [](#todatetime2)toDateTime(str: String, format: String | Null = null, locale: String | Null = null): DateTime

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

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

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

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

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

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

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