Java Day of parseDay(String str, String type)

Here you can find the source of parseDay(String str, String type)

Description

parse Day

License

Apache License

Declaration

public static String parseDay(String str, String type)
            throws ParseException 

Method Source Code

//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;
    }
}

Related

  1. parseBirthday(String r)
  2. parseCalendarDayFormat(String strDate)
  3. parseDay(Date value, String defaultValue)
  4. parseDay(final String day)
  5. parseDay(int time)
  6. parseDayTime(long ts)
  7. parseFromDays(String date)
  8. plusDay(Date date, int day)
  9. plusDays(Date date, int days)