英文月份和数字月份转换

public static List MONTH_LIST = Arrays.asList("JAN", "FEB", "MAR",
   "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC");



public static String changeNumberToChar(String releaseVersion) {

  if (null == releaseVersion) {
   throw new IllegalArgumentException("ReleaseVersion cannot be null");
  }
  String strNumber = releaseVersion.substring(0, 2);
  String strMonth = null;
  try {
   strMonth = MONTH_LIST.get(Integer.parseInt(strNumber));
  } catch (NumberFormatException e) {
   e.printStackTrace();
   System.out.println("Parse month error........");
  }
  return strMonth + releaseVersion.substring(2);
 }

 public static String changeStringToNumber(String releaseVersion) {
  if (null == releaseVersion) {
   throw new IllegalArgumentException("ReleaseVersion cannot be null");
  }
  for (int i = 0; i < MONTH_LIST.size(); i++) {
   if (releaseVersion.toUpperCase().startsWith(MONTH_LIST.get(i))) {
    if (i < 10) {
     return "0" + i;
    }
    return i + "";
   }
  }
  return -1 + "";
 }

 

你可能感兴趣的:(code-fragment)