Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

required format

 
Naresh Babu
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my class , the code :
String q1 ="select to_char(startdate , 'dd/mm/yy hh:mi:ss') from emp";

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(q1);
while(rs.next())
{
System.out.printl(rs.getString(1));
}

The o/p: 2001-01-20 10:00:00 .
But, shouldnt it print 20/01/01 10:00:00 since i am getting the column value using rs.getString(x) and also in query i am
using to_char(x,x) for the required format.
Do i have to set some values at the java side .
I am using oracle JDBC driver.
Any help is appreciated.
thanks
Naresh.


[This message has been edited by Naresh Babu (edited April 28, 2001).]
 
Daniel Dunleavy
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't to answer your question but ...one thing
in Oracle you use hh24 if you want the hour to be 10 (am) or 22 (pm). Otherwise it would be 10 for either am or pm
Dan
 
Naresh Babu
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone please suggest me a way ...
thanks
Originally posted by Naresh Babu:
Hi,
In my class , the code :
String q1 ="select to_char(startdate , 'dd/mm/yy hh:mi:ss') from emp";

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(q1);
while(rs.next())
{
System.out.printl(rs.getString(1));
}

The o/p: 2001-01-20 10:00:00 .
But, shouldnt it print 20/01/01 10:00:00 since i am getting the column value using rs.getString(x) and also in query i am
using to_char(x,x) for the required format.
Do i have to set some values at the java side .
I am using oracle JDBC driver.
Any help is appreciated.
thanks
Naresh.


[This message has been edited by Naresh Babu (edited April 28, 2001).]

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic