Here you can find the source of parseDay(String str, String type)
public static String parseDay(String str, String type) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String parseDay(String str, String type) throws ParseException { if (type.equals("single")) { return "single"; }//from ww w. ja va 2 s . co m if (type.equals("day")) { return str; } SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); Date d = fmt.parse(str); SimpleDateFormat fmtmonth = new SimpleDateFormat("yyyyMM"); if (type.equals("month")) { return fmtmonth.format(d); } SimpleDateFormat fmtrtn = new SimpleDateFormat("dd"); Integer rtn = Integer.parseInt(fmtrtn.format(d)); String xun = "1"; if (rtn > 10) { xun = "2"; } if (rtn > 20) { xun = "3"; } return fmtmonth.format(d) + xun; } }