Parsing a date’s ordinal indicator ( st, nd, rd, th ) in a date-time string

Java’s SimpleDateFormat doesn’t support an ordinal suffix, but the ordinal suffix is just eye candy – it is redundant and can easily be removed to allow a straightforward parse: Date date = new SimpleDateFormat(“MMM dd yyyy hh:mma”) .parse(str.replaceAll(“(?<=\\d)(st|nd|rd|th)”, “”)); The replace regex is so simple because those sequences won’t appear anywhere else in a valid … Read more