Here you can find the source of dateToString(String date, String month)
Parameter | Description |
---|---|
date | date |
month | month |
public static String dateToString(String date, String month)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .j av a 2s . c o m * @param date date * @param month month * @return date in string form [ mmdd ] */ public static String dateToString(String date, String month) { if (date.length() == 1) date = "0" + date; return monthAlphaToNum(month) + date; } /** * @param date date * @param month month * @param year year * @return date in string form [ yyyymmdd ] */ public static String dateToString(String date, String month, String year) { if (year == null) return dateToString(date, month); if (date.length() == 1) date = "0" + date; return year + monthAlphaToNum(month) + date; } /** * Month string to number * @param str month in string * @return month in number */ private static String monthAlphaToNum(String str) { str = str.toLowerCase(); if (str.equals("jan") || str.equals("january")) { return "01"; } else if (str.equals("feb") || str.equals("february")) { return "02"; } else if (str.equals("mar") || str.equals("march")) { return "03"; } else if (str.equals("apr") || str.equals("april")) { return "04"; } else if (str.equals("may")) { return "05"; } else if (str.equals("jun") || str.equals("june")) { return "06"; } else if (str.equals("jul") || str.equals("july")) { return "07"; } else if (str.equals("aug") || str.equals("august")) { return "08"; } else if (str.equals("sep") || str.equals("september")) { return "09"; } else if (str.equals("oct") || str.equals("october")) { return "10"; } else if (str.equals("nov") || str.equals("november")) { return "11"; } else if (str.equals("dec") || str.equals("december")) { return "12"; } return null; } }