<%@ page import="java.text.SimpleDateFormat" %> <%@ page import="java.util.Calendar" %> <%@ page import="java.util.Date" %> <%@ page import="java.util.GregorianCalendar" %> <html> <head> <title>ThaiCreate.Com JSP Tutorial</title> </head> <body> <% Date date = new Date(); out.println("<br>Current Date : " + date.toString()); out.println("<br>=============================="); String fm; fm = String.format("%s %tB %<te, %<tY", "Current Date : ", date); out.println("<br>" + fm); out.println("<br>=============================="); Date now = new Date(); SimpleDateFormat sf = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); out.println("<br>Current Date: " + sf.format(now)); out.println("<br>=============================="); Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentDate = df.format(c.getTime()); out.println("<br>Current Date : " + currentDate); out.println("<br>=============================="); GregorianCalendar gc = new GregorianCalendar(); out.println("<br>Year : " + gc.get(Calendar.YEAR)); out.println("<br>Month : " + gc.get(Calendar.MONTH)); out.println("<br>Day : " + gc.get(Calendar.DATE)); out.println("<br>Hour : " + gc.get(Calendar.HOUR)); out.println("<br>Minute : " + gc.get(Calendar.MINUTE)); out.println("<br>Second : " + gc.get(Calendar.SECOND)); %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท