Java Month Calculate getMonthFormat(String date)

Here you can find the source of getMonthFormat(String date)

Description

get Month Format

License

Open Source License

Declaration

public static String getMonthFormat(String date) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    public static String getMonthFormat(String date) {
        date = deleteDash(date);/*from   w  ww  .  ja v a 2s  . c om*/
        return (date.substring(0, 4) + "-" + date.substring(4, 6));
    }

    public static String deleteDash(String value) {

        return deleteChar(value, "-");
    }

    public static String deleteChar(String source, String deleteStr) {
        if (source == null || "".equals(source.trim())) {
            return "";
        }
        StringBuffer temp = new StringBuffer("");
        StringTokenizer st = new StringTokenizer(source, deleteStr);

        while (st.hasMoreTokens()) {
            temp.append(st.nextToken());
        }

        return temp.toString();
    }
}

Related

  1. getDiffInMonths(Date firstDate, Date lastDate)
  2. getDisplayMonth(int month)
  3. getIntMonthShift(Date Shift)
  4. getlastDateofThisMonth()
  5. getLastMonthBegin()
  6. getMonthlyIntervals(Date start, Date end)
  7. getMonthNumber()
  8. getMonthsMap()
  9. getMonthsOfAge(Date birth, Date now)