• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How does a parse method in Date class work

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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));
}
}
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Honk if you love justice! And honk twice for tiny ads!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic