From mm / DD / yyyy to dd-mmm-yyyy in Java
•
Java
Is there a method in Java that can convert mm / DD / yyyy to dd-mmm-yyyy?
For example: 05 / 01 / 1999 to 01-may-99
thank you!
Solution
Use simpledateformat to parse the date, and then print it out in the desired format
Here are some codes:
SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy"); Date date = format1.parse("05/01/1999"); System.out.println(format2.format(date));
Output:
01-May-99
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码