|
Hey Gurus,
Mike.
.shtml =====
<HTML> <HEAD><TITLE>Times!</TITLE></HEAD> <BODY> The current time here is: <SERVLET CODE=/Servlets/CurrentTime> </SERVLET> <P> The current time in London is: <SERVLET CODE=/Servlets/CurrentTime> <PARAM NAME=zone VALUE=GMT> </SERVLET> <P> And the current time in New York is: <SERVLET CODE=/Servlets/CurrentTime> <PARAM NAME=zone VALUE=EST> </SERVLET> <P> </BODY> </HTML>
servlet code ========
public class CurrentTime extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = resp.getWriter(); resp.setContentType("text/html");
Date date = new Date(); DateFormat df = DateFormat.getInstance(); String zone = req.getParameter("zone");
if(zone != null) { TimeZone tz = TimeZone.getTimeZone(zone); df.setTimeZone(tz); }
out.println(df.format(date));
}
}
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.