Java dateformat: how to handle “ST”, “nd”, “Rd”, “th”?
•
Java
How to use some dateformats to parse such strings?
As far as I know, there is nothing in simpledateformat
Solution
Try this
String str = "Wednesday,24th July"; str = str.replaceAll("(\\d\\d)..","$1") + " " + Calendar.getInstance().get(Calendar.YEAR); Date date = new SimpleDateFormat("EEEE,dd MMMM yyyy",Locale.US).parse(str);
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
二维码