wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes How does a parse method in Date class work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How does a parse method in Date class work" Watch "How does a parse method in Date class work" New topic
Author

How does a parse method in Date class work

kiran mohan
Greenhorn

Joined: Mar 16, 2005
Posts: 18
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

Joined: May 20, 2005
Posts: 61
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.


-Rich, SCJP 1.4
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How does a parse method in Date class work