Date conversion 12-5 months-2014 converted to 2014-05-12

Source: Internet
Author: User

/**

  *这个日期格式的转化,可以用一个类SimpleDateFormat,   *你这种好像不行,特殊的就要特殊处理,   *下面的只是一个简单的方法,还有其他的方法   *   */ public class Test {      private String monthChange(String month){          String result= null ;          switch (month) {          case "十二月" :              result= "12" ;              break ;          case "十一月" :              result= "11" ;              break ;          case "十月" :              result= "10" ;              break ;          case "九月" :              result= "9" ;              break ;          case "八月" :              result= "8" ;              break ;          case "七月" :              result= "7" ;              break ;          case "六月" :              result= "6" ;              break ;          case "五月" :              result= "5" ;              break ;          case "四月" :              result= "4" ;              break ;          case "三月" :              result= "3" ;              break ;          case "二月" :              result= "2" ;              break ;          case "一月" :              result= "1" ;              break ;          default :              break ;          }          return result;      }           private String dateStrChange(String dateStr){          String[] date=dateStr.split( "-" );          date[ 1 ]=monthChange(date[ 1 ]);          return date[ 2 ]+ "-" +date[ 1 ]+ "-" +date[ 0 ];      }      /**       * @param args       */      public static void main(String[] args) {          String str1= "02-十二月-2014" ;          str1= new Test().dateStrChange(str1);          System.out.println(str1);               } }

Date conversion 12-5 months-2014 converted to 2014-05-12

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.