How to get month name and am / pm in lower case

How to get month name and am / pm in lower case

DateTime.Now.ToString("MMMM h:m tt"); 


this gives me uppercase letters, but I need small letters.

+4
source share
3 answers

You just need to use the ToLower method

 DateTime.Now.ToString("MMMM h:m tt").ToLower(); 
+15
source

Given that everything else will be numeric, I think the easiest way to call ToLower as a result. I don’t think you can do something in the format string to make it reduce case.

+4
source

You can use DateFormat Class and this static method will convert it to lower am pm

  Calendar calendar = Calendar.getInstance(); String inFormat = "d MMM yyyy,h:mm aa"; String dateString = DateFormat.format(inFormat, calendar).toString(); 

By converting the string to lowercase (which you do), your month will also be converted to lowercase, suppose your month is July , then it will be converted to July . I think you can use the above method to convert specifically only am_pm to lowercase

0
source

Source: https://habr.com/ru/post/1344333/


All Articles