converting date format

后端 未结 5 1432
我寻月下人不归
我寻月下人不归 2020-12-04 03:00

I got date as \'14-Dec-2010\' i want to get the month in number format for the given date. that is., i want to convert the date to \'14-12-2010\'.<

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 03:48

    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    public class DateFormatter {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            Date date = new Date("14-Dec-2010"); //deprecated. change it to your needs
            DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
            System.out.println(df.format(date));
    
        }
    
    }
    

提交回复
热议问题