开发者

Date format in JAVA

开发者 https://www.devze.com 2023-01-05 00:42 出处:网络
Iwant to print April as APR IN JAVA WHERE 4 comes as paramete开发者_如何学Pythonr to indicate April. what can i do?i tried the format \'MMM\' but it prints \'Apr\' in stead of \'APR\'.Use the String.t

I want to print April as APR IN JAVA WHERE 4 comes as paramete开发者_如何学Pythonr to indicate April. what can i do?i tried the format 'MMM' but it prints 'Apr' in stead of 'APR'.


Use the String.toUpperCase() method.


why not just upper case your 'MMM' result ?


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...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消