Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

JSP: Afficher toutes les informations de la Date avec la classe Calendar

<%@ page import="java.util.*" %>
<HTML>
    <HEAD>
        <TITLE>Les champs de la classe Calendar</TITLE>
    </HEAD>
 
    <BODY>
        <H1>Liste des information disponible sur la date</H1>
        <%
            String dateString = new String();
 
GregorianCalendar calendrier = new GregorianCalendar ();
Date date1 = new Date ();
calendar.setTime (date1);
 
dateString + = "Calendar.YEAR est" + calendar.get (Calendar.YEAR) + "<BR>";
dateString + = "Calendar.MONTH est" + calendar.get (Calendar.MONTH) + "<BR>";
dateString + = "Calendar.WEEK_OF_YEAR est" + calendar.get (Calendar.WEEK_OF_YEAR) +
"<BR>";
dateString + = "Calendar.WEEK_OF_MONTH est" + calendar.get (Calendar.WEEK_OF_MONTH)
+ "<BR>";
dateString + = "Calendar.DATE est" + calendar.get (Calendar.DATE) + "<BR>";
dateString + = "Calendar.DAY_OF_MONTH est" + calendar.get (Calendar.DAY_OF_MONTH) +
"<BR>";
dateString + = "Calendar.DAY_OF_YEAR est" + calendar.get (Calendar.DAY_OF_YEAR) +
"<BR>";
dateString + = "Calendar.DAY_OF_WEEK est" + calendar.get (Calendar.DAY_OF_WEEK) +
"<BR>";
dateString + = "Calendar.DAY_OF_WEEK_IN_MONTH est"
+ Calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH) + "<BR>";
dateString + = "Calendar.AM_PM est" + calendar.get (Calendar.AM_PM) + "<BR>";
dateString + = "Calendar.HOUR est" + calendar.get (Calendar.HOUR) + "<BR>";
dateString + = "Calendar.HOUR_OF_DAY est" + calendar.get (Calendar.HOUR_OF_DAY) +
"<BR>";
dateString + = "Calendar.MINUTE est" + calendar.get (Calendar.MINUTE) + "<BR>";
dateString + = "Calendar.SECOND est" + calendar.get (Calendar.SECOND) + "<BR>";
dateString + = "Calendar.MILLISECOND est" + calendar.get (Calendar.MILLISECOND) +
"<BR>";
 
dateString + = "Réglage de la date <BR>!";
 
calendar.set (2005, 11, 31, 23, 59);
 
dateString + = "Calendar.YEAR est" + calendar.get (Calendar.YEAR) + "<BR>";
dateString + = "Calendar.MONTH est" + calendar.get (Calendar.MONTH) + "<BR>";
dateString + = "Calendar.WEEK_OF_YEAR est" + calendar.get (Calendar.WEEK_OF_YEAR) +
"<BR>";
dateString + = "Calendar.WEEK_OF_MONTH est" + calendar.get (Calendar.WEEK_OF_MONTH)
+ "<BR>";
dateString + = "Calendar.DATE est" + calendar.get (Calendar.DATE) + "<BR>";
dateString + = "Calendar.DAY_OF_MONTH est" + calendar.get (Calendar.DAY_OF_MONTH) +
"<BR>";
dateString + = "Calendar.DAY_OF_YEAR est" + calendar.get (Calendar.DAY_OF_YEAR) +
"<BR>";
dateString + = "Calendar.DAY_OF_WEEK est" + calendar.get (Calendar.DAY_OF_WEEK) +
"<BR>";
dateString + = "Calendar.DAY_OF_WEEK_IN_MONTH est"
+ Calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH) + "<BR>";
dateString + = "Calendar.AM_PM est" + calendar.get (Calendar.AM_PM) + "<BR>";
dateString + = "Calendar.HOUR est" + calendar.get (Calendar.HOUR) + "<BR>";
dateString + = "Calendar.HOUR_OF_DAY est" + calendar.get (Calendar.HOUR_OF_DAY) +
"<BR>";
dateString + = "Calendar.MINUTE est" + calendar.get (Calendar.MINUTE) + "<BR>";
dateString + = "Calendar.SECOND est" + calendar.get (Calendar.SECOND) + "<BR>";
dateString + = "Calendar.MILLISECOND est" + calendar.get (Calendar.MILLISECOND) +
"<BR>";
out.println (dateString);
%>
    </BODY>
</HTML>
 
           
       

A Voir sur le même Sujet:

  • afficher la date sur une page jsp
  • jsp afficher page