문제

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