• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does a parse method in Date class work

 
kiran mohan
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai guys , how does a parse method of a date class work, i am totally confused how does it work.

plz check out this program and plz help me how does the parse method works


public class DateProg
{
psnm(String args[])
{
String date="050716"
ParsePosition p = new ParsePosition(0);
SimpleDateFormat sdate=new SimpleDateFormat("yyMMdd");
Date dt = sdate.parse(date,p);
System.out.println(sdate.format(dt));
sdate.applyPattern("yyyyMMdd");
System.out.println(sdate.format(dt));
}
}
 
Richard Anderson
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what results do you get when you run this program? I would change the method signature of your method to:
public static void main (String[] args)
and add a semicolon after 050716.

Let me know if what you get is what you intended.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic