riyana
riyana

Reputation: 21705

Date format in JAVA

I want to print April as APR IN JAVA WHERE 4 comes as parameter to indicate April. what can i do?i tried the format 'MMM' but it prints 'Apr' in stead of 'APR'.

Upvotes: 1

Views: 239

Answers (4)

Tushar Tarkas
Tushar Tarkas

Reputation: 1612

Use String.subString and then apply String.toUpperCase to get desired result.

Upvotes: 1

Alban Soupper
Alban Soupper

Reputation: 721

With the SimpleDateFormat class you cannot or use String.toUpperCase() (as said Ben J) in conjunction with the "MMM".

This makes sense if you work with dates but if you just work with numbers (ie: 4) you can build a complete switch statement on the number...

Upvotes: 1

Ben J
Ben J

Reputation: 5871

Use the String.toUpperCase() method.

Upvotes: 4

Jason
Jason

Reputation: 847

why not just upper case your 'MMM' result ?

Upvotes: 4

Related Questions