Here you can find the source of getYear(boolean fourDigit)
public static String getYear(boolean fourDigit)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005-2012 Synopsys, Incorporated * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w.j a va 2 s . c o m * Synopsys, Inc - Initial implementation *******************************************************************************/ import java.util.Calendar; public class Main { private static Calendar mCalendar = null; /** * Returns the current Year as a string (e.g. 2003). * @return the current year as a string. */ public static String getYear(boolean fourDigit) { if (mCalendar == null) Init(); String year = mCalendar.get(Calendar.YEAR) + ""; if (year.length() == 4 && fourDigit) return year; return year.substring(2); } /** * This method creates a new Calendar object */ public static void Init() { mCalendar = Calendar.getInstance(); } }