Reputation: 39
String.format(start.toString("dd-MMM-YYYY HH:mm"));
where start is a date input in LocalDateTime
class from org.joda.time
api
when i am using this code, its returning month like this "Dec" but i want the output as "DEC".
Upvotes: 0
Views: 9015
Reputation: 39
I always using substring, in my case like this :
String sDate = String.format(start.toString("dd-MMM-YYYY HH:mm"));
String oDate = sDate.substring(0, 2)+"-"+sDate.substring(3, 6).toUppercase()+"-"+sDate.substring(7, 11);
Upvotes: 1
Reputation: 1852
If this (String.format(start.toString("dd-MMM-YYYY HH:mm"));) retrieves the correct format of what you want, then you can simply use
String.format(start.toString("dd-MMM-YYYY HH:mm")).toUpperCase();
Upvotes: 2
Reputation: 8771
The only way will be to replace a substring by the uppercase version.
Date start = new Date();
SimpleDateFormat oFormat = new SimpleDateFormat("dd-MMM-YYYY HH:mm");
String sDate = oFormat.format(start);
System.out.println(sDate);
sDate = sDate.substring(0,3) + sDate.substring(3,6).toUpperCase() + sDate.substring(6,sDate.length());
System.out.println(sDate);
Upvotes: 0