Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

date format  RSS feed

 
Rajendra Nath
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

SimpleDateFormat dateformat=new SimpleDateFormat("MM-dd-yyyy");
System.out.println("Formated date:"+dateformat.format(dd)); String parsedate=dateformat.format(dd);

which prints this output
Formated date:02-02-2007

i am also using the date picker in a jsp, which prints the date as 2-2-2007.
there is a problem with these date formats. date picker gives the date as 2-2-2007, but the java code gives the date prepending with 0.
can you please help me. as there is a problem with executing the sql query.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a problem with these date formats. date picker gives the date as 2-2-2007, but the java code gives the date prepending with 0.
can you please help me. as there is a problem with executing the sql query.

So can you please explain what you want exactly? Do you want Java to format the date without the leading zeroes? If that is what you want, then use the format "M-d-yyyy" instead of "MM-dd-yyyy".

What is the problem with the SQL query?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!