How to get current Century from a date in Java?
For example the date \"06/03/2011\"
according to format \"MM/dd/yyyy\"
. How can I get curre
Split it by the slahes, get the first two symbols of the third element in the resulting array, Integer.parseInt it and add 1, that is:
(not sure about the substring() syntax off the top of my head)
String arr = myDate.split("/");
String shortYear = myDate[2].substring(0, 2);
int century = Integer.parseInt(shortYear) + 1;