How can I convert this date 26-11-2013 in this format nov 26. I have tried many things but didn't work for me. Like

SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
        String dateInString = "26-11-2013";
Date date = formatter.parse(dateInString);
            System.out.println(date);
有帮助吗?

解决方案

You will have to use another formatter for the desired output format.

SimpleDateFormat outputFormat = new SimpleDateFormat("MMM dd");
SimpleDateFormat inputFormat = new SimpleDateFormat("dd-MM-yyyy");
String dateInString = "26-11-2013";
Date date = inputFormat.parse(dateInString);
System.out.println(outputFormat.format(date));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top