Java Date to Year getYearMonth(Date date)

Here you can find the source of getYearMonth(Date date)

Description

get Year Month

License

Apache License

Declaration

public static String getYearMonth(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static String getYearMonth(Date date) {
        Calendar c = new GregorianCalendar();
        c.setTime(date);/*from w  ww  .j  a  v  a 2  s . co m*/
        return c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1);
    }
}

Related

  1. getYearAsInt(Date aDate)
  2. getYearBegin(final Date date)
  3. getYearBetweenTwoDate(Date fdate, Date tdate)
  4. getYearFromDate(Date date)
  5. getYearFromDate(Date date)
  6. getYearMonthDay(Date date)
  7. getYearMonthDay(Date date)
  8. getYearMonthInt(Date date)
  9. getYearMonthOfLastMon(Date date)