Here you can find the source of getYear(String sdate)
public static String getYear(String sdate)
//package com.java2s; /**/*from w w w . jav a 2 s .co m*/ * * Copyright (c) 2012 ChinaSoft International Co., Ltd. * All rights reserved. * This software is the confidential and proprietary information of * ChinaSoft International. ("Confidential Information"). * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of the license agreement you entered * into with ChinaSoft International. * * ????????? * 2012-5-21 ?? */ import java.util.Calendar; public class Main { public static String getYear(String sdate) { String[] date = sdate.split("-"); return date[0]; } public static String getYear(java.util.Date date) { Calendar cale = Calendar.getInstance(); cale.setTime(date); return Integer.toString(cale.get(Calendar.YEAR)); } }