|
Revision 34, 0.9 KB
(checked in by yabuki, 3 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.*"%> |
|---|
| 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.setDefault(new Locale("ja", "JP")); |
|---|
| 12 | |
|---|
| 13 | //現在の日時を取得 |
|---|
| 14 | Calendar cal=Calendar.getInstance(); |
|---|
| 15 | |
|---|
| 16 | //日付の表示形式を定義し,実際に表示する |
|---|
| 17 | DateFormat fmt=DateFormat.getDateInstance(DateFormat.FULL); |
|---|
| 18 | out.print("<p>"+fmt.format(cal.getTime())+"</p>"); |
|---|
| 19 | |
|---|
| 20 | fmt=new SimpleDateFormat("yyyy-M-d"); |
|---|
| 21 | out.print("<p>"+fmt.format(cal.getTime())+"</p>"); |
|---|
| 22 | |
|---|
| 23 | cal.set(1582, Calendar.OCTOBER, 4); |
|---|
| 24 | cal.add(Calendar.DAY_OF_MONTH, 1); |
|---|
| 25 | out.print("<p>"+fmt.format(cal.getTime())+"</p>"); |
|---|
| 26 | %> |
|---|
| 27 | </body> |
|---|
| 28 | </html> |
|---|