java - How to parse date with letters after date number -
this question has answer here:
i know how use simpledateformat in java. nicest way parse dates has letters after day number? these: "25th may 2014", "3rd may 2014", "1st may 2014". see how letters different? not want create separate formater every number ending. re better way in java?
you convert of them common 1 using replaceall
put 1 in single formatter string.
thedate = thedate.replaceall("(?:(st|nd|rd|th))","xx"); if (thedate.contains("guxx")) // handle fixing "august" becoming "auguxx" thedate = thedate.replace("guxx","gust");
this change 1st 2nd 3rd 4th 5th
1xx 2xx 3xx 4xx 5xx
. can use static string 'xx' in pattern.
Comments
Post a Comment