Hello,大家好!我是程序员阿飞!今天主要学习的内容是:将世界标准时间(字符串)转换成特定格式时间(字符串)。好了,直接进入正题。

    1、代码示例

         /***

         * 将世界标准时间(字符串)转成特定格式时间(字符串)

         * @time  : 2019-03-11 15:43

         * @author: wnf

         * @descript:

         */

        public static String format(String time){

                   Date d2 = null;

                   String format= null;

                if(time!=null && !"".equals(time)){

                          SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'CST' yyyy", Locale.ENGLISH);

                          SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                          try {

                               d2 = sdf.parse(time);

                              format = formatter.format(d2);

                          } catch (ParseException e) {

                               e.printStackTrace();

                          }

                          return format;

                }

                return format;

        }