To get only year from a date you can use the below code. You can pass any date that you wan to change, I'm getting year from the date in the below example:
/**
* Get year from Date
*
* @param createDate
* @return
*/
public static String getYear(Date createDate)
{
SimpleDateFormat simple = new SimpleDateFormat();
simple.applyPattern("yyyy");
return simple.format(createDate);
}
0 Comment(s)