Hi,
In a
string i have "01/02/2002", i want to extract the year part.
Probably I can just use substring and extract year.
But I am doing this, just wanted to know is this right? Seems unnecessary.
String strDate = "01/02/2002";
DecimalFormat fmt100 = new DecimalFormat("0000");
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
Calendar _calender = Calendar.getInstance();
Date parsed = format.parse(strDate);
_calender.setTime(parsed);
System.out.println (fmt100.format(_calender.get(Calendar.YEAR))); //prints 2002