Java Date to Year getYear(String sdate)

Here you can find the source of getYear(String sdate)

Description

get Year

License

Open Source License

Declaration

public static String getYear(String sdate) 

Method Source Code

//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));
    }
}

Related

  1. getYear(final Date date)
  2. getYear(final Date date)
  3. getYear(final Date date)
  4. getYear(java.util.Date date)
  5. getYear(java.util.Date today)
  6. getYear(String strDate)
  7. getYearAsInt(Date aDate)
  8. getYearBegin(final Date date)
  9. getYearBetweenTwoDate(Date fdate, Date tdate)