Displaying the last two digits of the current year in Java

You can simply use the modulo operator:

int lastTwoDigits = Calendar.getInstance().get(Calendar.YEAR) % 100;

Edit: Using a SimpleDateFormat, as @R.J proposed, is the better solution if you want the result to be a string. If you need an integer, use modulo.

Leave a Comment

techhipbettruvabetnorabahisbahis forumuedueduedueduseduseduseduedusedusedu