Here you can find the source of getMonthFormat(String date)
public static String getMonthFormat(String date)
//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(); } }