timeOfMark = Calendar.getInstance(Locale.ENGLISH);
Map<String, Integer> what = timeOfMark.getDisplayNames(Calendar.HOUR, Calendar.SHORT, Locale.ENGLISH);
for(Map.Entry<String, Integer> pair : what.entrySet())
{
Log.e(pair.getKey(), Integer.toString(pair.getValue()));
}
This case crashes my android app, because Log.e cannot accept null string.
It is same thing with
timeOfMark.getDisplayName(Calendar.HOUR, Calendar.SHORT, Locale.ENGLISH);
I tried many variations with input parameters. For locale I also did Locale.getDefault() and many other. Still same **
No darn luck. Is there anything to solve this? Or a easy workaround?
public Map getDisplayNames(int field,int style,Locale locale)
This method returns a Map containing all display names in style and locale and their field values, or null
if no string representation is available.
timeOfMark.getDisplayName(Calendar.HOUR, Calendar.SHORT, Locale.ENGLISH);
There is not String representation of HOUR, i.e you can express HOURS
in string
like we did for MONTH And DAY_OF_WEEK
Try WEEK, MONTH Example
Map< String, Integer> representations =
now.getDisplayNames(Calendar.MONTH, Calendar.ALL_STYLES, locale);
You will get
{Apr=3, April=3, Aug=7, August=7, Dec=11, December=11, Feb=1, February=1, Jan=0, January=0, Jul=6, July=6, Jun=5, June=5, Mar=2, March=2, May=4, Nov=10, November=10, Oct=9, October=9, Sep=8, September=8}
For Calendar.DAY_OF_WEEK
{Fri=6, Friday=6, Mon=2, Monday=2, Sat=7, Saturday=7, Sun=1, Sunday=1, Thu=5, Thursday=5, Tue=3, Tuesday=3, Wed=4, Wednesday=4}
Try here
http://www.browxy.com/SubmittedCode/18596
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With