Link to home
Start Free TrialLog in
Avatar of SiemensSEN
SiemensSEN

asked on

change the format of a date field in JAVA

How do I convert a date field [Jan 17, 2014 5:57:05 PM] to  yyyy-mm-dd HH::MM::ss

--My Definition--
Date timestamp;

--get the value--
this.timestamp= (Date)sd.getFieldValue("timestamp");


Thanks for your help
SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
to  yyyy-mm-dd HH::MM::ss
If you have a variable of type java.sql.Timestamp, its toString method will give you that format
Avatar of SiemensSEN
SiemensSEN

ASKER

I am reading the date information from SOLR database. The date field in define as a 'Date' type
I am reading the date information from SOLR database. The date field in SOLR define as a 'Date' type  and I need to return a variable of type date with format(yyyy-mm-dd HH:MM:SS)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry ...

The value is I get from SOLR is of type DATE e.g Jan 17, 2014 5:57:05 PM
I would like to convert it to format (yyyy-mm-dd HH:MM:ss) and return this value as type 'Date'

Thanks for your help . I will try to debug with your suggession
The value is I get from SOLR is of type DATE
This is the Java TA. Which Java type do you get?
Java.util.Date
OK good. See my previous code example
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)