I am using the below method to get this string to_date('2011/06/02','yyyy/mm/dd')
private static String getOperationDate() {
Date today= new Date();
String output;
SimpleDateFormat formatter;
String pattern="yyyy/MM/dd";
formatter = new SimpleDateFormat(pattern, Locale.US);
output = formatter.format(today);
String temp="to_date('"+output+"','yyyy/mm/dd')";
return temp;
}
How can i generate something like this to_date('2011-05-27 12:45:56.1',....) i.e., apart from just date how can i also include time with milliseconds, which would then be updated to the database
Added a oracle insert statement, after referring to an answer by trutheality, but this gives me 01810. 00000 - "format code appears twice" error
INSERT INTO CONFIG_INFO(CFG_ID,CFG_NAME,CFG_DESC,CFG_TYPE,FILE_NAME,ABSOLUTE_PATH,EMAIL_ADDRESS,PROJECT_ID,HOSTNAME,CREATE_DATE,UPDATE_DATE,STATE,PRODUCT_ID)
VALUES (config_seq.NEXTVAL,'Abhishek','as','Production','asdclient1.xml','E:tomcat 5.5bin/../webapps/asd/files/asdclient.xml','a@a.com','ABC','abhinix',to_date('2011/06/02 11:18:38.211','yyyy/MM/dd HH:mm:ss.SSS'),to_date('2011/06/02 11:18:38.211','yyyy/MM/dd HH:mm:ss.SSS'),2,123456)
Look at the docs, and figure out what your format string should be.
Probably something like
But the proper way is to use the JDBC driver as OMG Ponies has pointed out.