|
Revision 51, 1.4 KB
(checked in by yabuki, 2 years ago)
|
|
|
-
Property svn:mime-type set to
text/plain
|
| Line | |
|---|
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
|---|
| 2 | <%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,java.text.*,com.ibm.icu.util.JapaneseCalendar"%> |
|---|
| 3 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 4 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 5 | <head> |
|---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|---|
| 7 | <title>Calendarの使い方</title> |
|---|
| 8 | </head> |
|---|
| 9 | <body> |
|---|
| 10 | <% |
|---|
| 11 | //Localeのvariant(3番目)をJPにして利用する(ふつうはLocale("ja","JP")) |
|---|
| 12 | Locale.setDefault(new Locale("ja", "JP", "JP")); |
|---|
| 13 | |
|---|
| 14 | //表示形式(Gが年号) |
|---|
| 15 | DateFormat format=new SimpleDateFormat("GGGGy年MMMMd日 H時m分s秒 z"); |
|---|
| 16 | |
|---|
| 17 | Calendar japImpCal = Calendar.getInstance(); |
|---|
| 18 | out.print("<p>"+format.format(japImpCal.getTime())+"</p>"); |
|---|
| 19 | |
|---|
| 20 | JapaneseCalendar jCal=new JapaneseCalendar(1,JapaneseCalendar.JANUARY,1,0,0,0); |
|---|
| 21 | jCal.set(Calendar.ERA,0); //最初の年号を調べる |
|---|
| 22 | |
|---|
| 23 | com.ibm.icu.text.DateFormatSymbols dfs=new com.ibm.icu.text.DateFormatSymbols(jCal, Locale.JAPANESE); |
|---|
| 24 | com.ibm.icu.text.SimpleDateFormat jFormat=new com.ibm.icu.text.SimpleDateFormat("Gy年M月d日 H時m分s秒 z",dfs); |
|---|
| 25 | |
|---|
| 26 | out.print("<p>"+jFormat.format(jCal)+" は "+jCal.getTime()+"です.</p>"); |
|---|
| 27 | |
|---|
| 28 | out.print("<p>"); |
|---|
| 29 | for (String era: dfs.getEras()) out.println(era+" "); |
|---|
| 30 | out.print("</p>"); |
|---|
| 31 | %> |
|---|
| 32 | </body> |
|---|
| 33 | </html> |
|---|