File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me in time comparison

 
albert sie
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have the code like this


but the current time that i get is in string type and i need to compare the time inside the database which is in time datatype..

how can i solve this problem...
please help me i stuck
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code will not compile. What is this line supposed to do?

float time=sdf2;

"but the current time that i get is in string type"

If you do Date d = new Date(); then you have a Date object that contains the time, not a String. You have to get the date out of the database first and then compare it to the current date in Java. Do you know how to get the date out of the database?

Please explain in more detail what you are trying to do, post some more of your code - otherwise it will be hard to help you...
 
debashis ghosh
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must have stored it in Date format in the database if I am not wrong.
And you want to convert the String in your code to date format.
you can do the following:

Date strdate=null;
SimpleDateFormat sdf2= new SimpleDateFormat("hh.mm");
strdate=sdf2.parse(Your date in String format);

Now that your String has been converted to Date format and stored in strdate,you can compare the two dates.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic