• Post Reply Bookmark Topic Watch Topic
  • New Topic

parse string to time  RSS feed

 
max soyosa
Greenhorn
Posts: 24
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi to everyone!

i have a problem about parsing string to time.
Here is my samplecode:

String time = request.getParameter("time");
Time tm = Time.parse(time);

but it goes error...

i tried another code like this...

String time = request.getParameter("time");
Time tm = Time.valueOf(time);

but it goes error too...

i tried also this code...

String time = request.getParameter("time");
DateFormat sdf = new SimpleDateFormat("hh:mm");
Time tm = (Time) sdf.parse(time);

it goes error too...
it says: Cannot parse Date to Time

my datatype of 'time' in database is time without time zone
what is wrong?

please help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should be using java.util.Date or java.util.Calendar not java.sql.Time.
 
max soyosa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahm, i have used java.util.date but it still goes error.
what should i do?

please give me a sample code...

thanks.
 
Paul Clapham
Sheriff
Posts: 22831
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
max soyosa wrote:my datatype of 'time' in database is time without time zone


And is that why you are asking this question? If so why is it a question about strings? Why don't you just get a Time object from the database?
 
max soyosa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahm, its just a clarification why i need to parse a string to time.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
max soyosa wrote:ahm, i have used java.util.date but it still goes error.
what should i do?

please give me a sample code...

thanks.
Just look at the (Simple)DateFormat class and you will be able to come up with something on your own.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!