Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int GetYear(boolean lastTwoDigitOnly) { Calendar now = Calendar.getInstance(); if (!lastTwoDigitOnly) return now.get(Calendar.YEAR); else return Integer.parseInt(String.valueOf(now.get(Calendar.YEAR)).substring(2, 4)); } }