• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting time with milliseconds in ResultSet

 
Eduardo Pinhata
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made a simple DB in MySQL



I'm trying to get the time with milliseconds using ResultSet and getTime() but I just get seconds with it. How can I also retrieve the milliseconds?

 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You define a "date" column and using getTime method?

Try the getTimestamp method and probably align the data type to Timestamp (if it's a data type in MySQL, can't recall)
 
Eduardo Pinhata
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you were right, I was supposed to change some of my code to use timestamp and it worked.
Next time I'll design my programs to use Timestamp from the beginning.

Thank you
 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another possibility: using a BIGINT column and use System.currentTimeMillis() as a value
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!