Java Year Month getYearMonth()

Here you can find the source of getYearMonth()

Description

get Year Month

License

Apache License

Declaration

public static long getYearMonth() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static long getYearMonth() {
        return getYearMonth(new Date());
    }//from w  w  w . ja v  a2  s  .  com

    public static long getYearMonth(Date date) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
        String str = dateFormat.format(date);
        return Long.parseLong(str);
    }

    public static String format(Date date, String p) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(p);
        return simpleDateFormat.format(date);
    }
}

Related

  1. getTheLastDayOfTheMonth(int year, int month)
  2. getThisYearMonth()
  3. getThisYearMonth()
  4. getTimeByYearMonth(String yearMonth, String timeZone)
  5. getYearAndMonth()
  6. getYearMonth()
  7. getYearMonth(Calendar sDate)
  8. getYearMonth(Date date)
  9. getYearMonth(Date date)