Pregunta

Can Java be used to get different styles of day_of_month?

i.e. "21st" and "22nd" rather than just "21" and "22"?

also what are the 'st' and 'nd' at the end of dates called for future reference?

¿Fue útil?

Solución

JDK (including Java 8) does not offer a solution out of the box, and other libraries like JodaTime also not. But you can look at this question on SO to get some ideas.

Furthermore, I think you can reasonably try your solution for ordinal day numbers only for English, but what about other languages? That is an important reason why no library can give support. In JodaTime or JSR-310 there might be an English-only handwritten solution possible on the base of introducing a specialized field, for example in JSR-310 the interface java.time.temporal.TemporalField, but this is surely a lot of work.

Otros consejos

No you may need to write a small utility function which will help you achieving the same in Java

you ca refer SO Answer here for the same here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top