Timezone in JSP

1st page:

<html>
 <body>
       <form action="print.jsp" method="post">
      Enter Time zone<input type="text" name="t1">
      <br>
       <input type="Submit" value="Submit">
       </form>
  </body>
</html>

Print.jsp:

<body>
        <%!
        String timezone;
        java.util.TimeZone t1;
        %>
        <%
        timezone=request.getParameter("t1");
        %>
        <jsp:useBean id="Timezone" class="TimePackage.timezone"/>
        <jsp:setProperty name="Timezone" property="time" value="<%= timezone%>"/>
        <jsp:getProperty name="Timezone" property="time"/>
         

    </body>

TimePackage package: (add a new package in the project under Source package and in it, create new class 'timezone')

public class timezone {
    TimeZone t1;
    long t;

    public void settime(String t)
    {
      t1=TimeZone.getTimeZone(t);
   
    }
    public String gettime()
    {
        Calendar calendar = new GregorianCalendar();
        calendar.setTimeZone(t1);
       t=calendar.getTimeInMillis();
      return Long.toString(t);
     
    }

}

RUN THE 1st PAGE. :)

Comments

Popular posts from this blog

Silde show of images In JSP

Compression ratio, Compression factor, saving percentage in C++

Working with database in Vb.net