Jsf-convertdatetime-tag
提供:Dev Guides
JSF-f:convertDateTime
f:convertDateTimeタグは、文字列値を必要な形式の日付に変換するために使用されます。 また、必須の日付形式であるバリデーターとしても機能します。
JSFタグ
タグ属性
S.No | Attribute & Description |
---|---|
1 |
type 日付(デフォルト)、時刻、またはその両方 |
2 |
dateStyle デフォルト、ショート、ミディアム、ロング、またはフル |
3 |
timeStyle デフォルト、ショート、ミディアム、ロング、またはフル |
4 |
pattern java.text.SimpleDateFormatで定義されているフォーマットパターン |
5 |
locale 解析および書式設定に使用されるプリファレンスのロケール |
6 |
timeZone 解析とフォーマットに使用するタイムゾーン |
応用例
上記のタグをテストするテストJSFアプリケーションを作成しましょう。
Step | Description |
---|---|
1 | Create a project with a name helloworld under a package com.finddevguides.test as explained in the JSF - First Application chapter. |
2 | Modify home.xhtml as explained below. Keep the rest of the files unchanged. |
3 | Create result.xhtml in the webapps directory as explained below. |
4 | Create UserData.java as a managed bean under package com.finddevguides.test as explained below. |
5 | Compile and run the application to make sure business logic is working as per the requirements. |
6 | Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver. |
7 | Launch your web application using appropriate URL as explained below in the last step. |
UserData.java
home.xhtml
result.xhtml
すべての変更を完了したら、JSF-最初のアプリケーションの章で行ったようにアプリケーションをコンパイルして実行します。 すべてがアプリケーションで問題ない場合、次の結果が生成されます。
無効な値を入力して、[送信]ボタンを押します。 次のエラーメッセージを参照してください。
有効な値を入力して、[送信]ボタンを押します。 次の結果を参照してください。