Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date format

 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have stored date in oracle database in dd/mm/yy format but when i retrieved date in pdf using this code ,it shows date in yyyy/mm/dd format ...but i want date in pdf in dd/mm/yyyy format.
 
Md. Minhajur Rahman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have stored date in oracle database in dd/mm/yy format in field name suppose date in table1, when you want to retrieve the date in dd/mm/yyyy format, you can change the query as follows...

 
Eshwin Sukhdeve
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this code
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");

String today = formatter.format(date);

System.out.println("Today : " + today);

 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Md. Minhajur Rahman wrote:If you have stored date in oracle database in dd/mm/yy format in field name suppose date in table1, when you want to retrieve the date in dd/mm/yyyy format, you can change the query as follows...


it is showing exception(document has no page) when i am doing this

show this exception

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

ExceptionConverter: java.io.IOException: The document has no pages.


root cause

java.io.IOException: The document has no pages.
com.itextpdf.text.pdf.PdfPages.writePageTree(PdfPages.java:113)
com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1217)
com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:787)
com.itextpdf.text.Document.close(Document.java:420)
LoginExample.generatepdf1.doPost(generatepdf1.java:155)
LoginExample.generatepdf1.doGet(generatepdf1.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.


--------------------------------------------------------------------------------
 
Manish Sridharan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please run the select query in db first and see if it is working fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic