Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display the time in miliseconds in a proper format in a JSP Page  RSS feed

 
Amit Roy
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I want to display the time returned by the lastModified() method in the File class in a JSP page in a proper format but as it is returning me a time in milisecs it is useless is ther any methos which will take in time in miliseconds and return me time in a priper format
thanks in Advance
Amit Roy
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi amit,
try
java.util.Calendar;
Calendar defines lots of constants to get
the different components of time(year/month etc)
Calendar c = Calendar.getInstance();;
c.setTime(long milliseconds);
then u can do a
c.get(Calendar.YEAR)..and so on.
hope it helps.
karthik
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or look up java.text.SimpleDateFormat which allows you to format the input and output of dates and times in almost any way you like.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!