• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Format date fetched from DB

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting a DateTime field from informix Database using hibernate and need to reformat my date as 2016-11-24 12:45:41

I am getting date as "updateTime": "2012-08-31T12:19:50.000+0000".

Please help in how to reformat the date.


Hibernate is retrieving Date as Timestamp from Database

 
Saloon Keeper
Posts: 14687
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross-posted at https://stackoverflow.com/questions/60922766/date-format-issue-with-hibernate-spring-informix

Pratibha, please notify all sites where you've posed your question of all other sites where you've posed your question. See BeForthrightWhenCrossPostingToOtherSites.
 
Marshal
Posts: 27531
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a Timestamp object. Sure, it came out of a database but it makes no difference where it came from. It's a Timestamp object. So your question is only "How do I format a Timestamp object?" You may find it easier to find answers to that question.
 
Stephan van Hulst
Saloon Keeper
Posts: 14687
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As some users on StackOverflow have said, your question is unclear.

It doesn't make sense at all to want to 'reformat' a time stamp, because a time stamp is not a string. A format is a property of a string. Now, please answer the following questions:

  • What is the type of the column in Informix?
  • What is the value of the field that is displayed when you look at it in the Informix user interface?
  • Does the value you get in Hibernate match the value you see in Informix?
  • Do you want to change the value you get in Hibernate to something different from what you see in Informix?
  • If you get matching values and you want to change the date and time in Hibernate, then WHY do you want to change it?
  •  
    reply
      Bookmark Topic Watch Topic
    • New Topic