Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Diem Tran   on Mar 27 In Java Category.

  
Question Answered By: Hu Chalthoum    on Mar 27

SimpleDateFormat dateFormatter = new SimpleDateFormat(
"MM/dd/yyyy");
ParsePosition parsePosition = new ParsePosition(0);
Calendar cal = Calendar.getInstance();
cal.setTime(dateFormatter.parse("03/03/2004",new
ParsePosition(0)));

This way you will get a refernce to calendar object.
Now you can get the values from the ref by using

int month  = cal.get(Calendar.MONTH) + 1;
int day  = cal.get(Calendar.DATE);
int year = cal.get(Calendar.YEAR);

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how to split a date value? Or get search suggestion and latest updates.


Tagged: