• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert the date to seconds?  RSS feed

 
Parul Saxena
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question regarding date conversion.

I need to set the maximum age of a cookie using a method that takes int(seconds) as argument.
I have a date "January 1, 2010", can anyone please help me to convert this date into seconds?

Please reply urgently.

Thanks & regards,
Saxena
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Saxena", please check your private messages for an important administrative matter.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the SimpleDateFormat class to create a Date object from the String and then use that date object to get the number of seconds.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!