Java Year Month getThisYearMonth()

Here you can find the source of getThisYearMonth()

Description

get This Year Month

License

Apache License

Declaration

public static String getThisYearMonth() throws ParseException 

Method Source Code

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

import java.text.ParseException;

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

public class Main {

    public static String getThisYearMonth() throws ParseException {
        return getYearMonth(new Date());
    }// w  w  w. j  ava 2s . c  o  m

    public static String getYearMonth(Date date) {
        Calendar today = Calendar.getInstance();
        today.setTime(date);
        return (today.get(Calendar.YEAR)) + "-"
                + ((today.get(Calendar.MONTH) + 1) >= 10 ? (today.get(Calendar.MONTH) + 1)
                        : ("0" + (today.get(Calendar.MONTH) + 1)));
    }
}

Related

  1. getMonthDays(Integer year, Integer month)
  2. getPerMonthByCuttentYear()
  3. getQuarterToYearMonthDay(Integer year, Integer quarter)
  4. getStartMonth(int year, int month)
  5. getTheLastDayOfTheMonth(int year, int month)
  6. getThisYearMonth()
  7. getTimeByYearMonth(String yearMonth, String timeZone)
  8. getYearAndMonth()
  9. getYearMonth()