Simple Implementation Method of jsp Countdown

  • 2021-08-31 08:48:39
  • OfStack

This paper describes the simple implementation method of jsp countdown with examples. Share it for your reference, as follows:


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
 // Current time milliseconds 
 Long current_time1=System.currentTimeMillis();
 // End time milliseconds 
 Long end_time2=1337875200000l;
 // Calculate time difference  
 Long time2=end_time2-current_time1;
   // Convert to seconds 
   int second=(int)(time2/1000); // Total seconds remaining 
   // Specify seconds as days 
   int s = second % 60; //  Seconds 
   int mi = (second - s) / 60 % 60; //  Minutes 
   int h = ((second - s) / 60 - mi ) / 60 % 24; //  Hours 
   int d = (((second - s) / 60 - mi ) / 60 - h ) / 24; //  Days 
   String ret= " Remaining: " + d + " Days " + h + " Hours " + mi + " Minutes " + s + " Seconds ";
   //System.out.println(ret);
%>

I hope this article is helpful to everyone's JSP programming.


Related articles: