2016-12-07 17 views
3

スロットタイプとしてAMAZON.DATEを使用すると、すべての種類の日付を入力できます。ドキュメンテーション: 「2015-12」、「2017-WI」(2017年の冬)、「2015-W48-WE」(2015年の第48週の週末)。これらの日付をJavaの日付/期間に解析したいのですが、これをどのように達成するのかと思います。Amazon Alexa:AMAZON.DATE to Java日付/時間

"2015-12"のような日付を取り、2つの日付または日付と期間を返すJavaライブラリがありますか? タイムゾーンの処理やあいまいな日付のような潜在的な問題が多数見えますが、これが一般的な問題であると考えています。

私は月の終わりのための月の1つのための1つの2つの日付としてそれを保存するパーサーを書くことができました。または、開始日と継続時間の日付ですが、これはISO 8601に準拠するためのオーバーヘッドのように思えます。

+0

'YearMonth.parse(" 2015-12 ")'? – assylias

+1

「2015-W48-WE」はどうですか?私はすべての可能な収入 'タイプ'のための異なる解析機能が必要になります。 –

答えて

3

Amazonのスキルサンプルには他の言語に変換するのがかなり簡単であるはずですa JavaScript AMAZON.DATE parserそれはスロットの値をとり、JavaScriptのDateオブジェクトを返します。コメントによると、それはすべての慣用的な日付形式を扱います。

// Utterances that map to the weekend for a specific week (such as 'this weekend') convert to a date indicating the week number and weekend: 2015-W49-WE. 
// Utterances that map to a month, but not a specific day (such as 'next month', or 'December') convert to a date with just the year and month: 2015-12. 
// Utterances that map to a year (such as 'next year') convert to a date containing just the year: 2016. 
// Utterances that map to a decade convert to a date indicating the decade: 201X. 
// Utterances that map to a season (such as 'next winter') convert to a date with the year and a season indicator: winter: WI, spring: SP, summer: SU, fall: FA) 
+1

ありがとうございます。私はこれをやっている人の例を見つけるのに夢中になってきました。とにかくそれを手作業で解析しなければならないことが分かります。 – Anthony