Android Shinobi Date Format Problem


#1

Dear All,

I set a date format in my Shinobi graph X-Axis, as below:

DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.PRC);

xAxis.setLabelFormat(df);

The problem is no matter how much i zoom in the graph, the date is always shown as “2014-1-13”, it won’t show in hours and minutes. Is this a bug?

Regards,

Victor


#2

I try changing the code to:

NumberFormat nf = NumberFormat.getInstance();

xAxis.getLabelFormat().setNumberFormat(nf);

However, there is NULL pointer error, xAxis.getLabelFormat() returns NULL pointer. Is this a bug in Shinobi?


#3

there is an example for shinobi iOS, how about Android?


#4

Hello Victor,

Thanks for getting in touch.

Please try this:

DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,  Locale.PRC);

This worked for me and correctly showed the time as well as the date.

xAxis.getLabelFormat() returns a user supplied label formatter. If you do not set this value in advance using setLabelFormat(), calling the method getLabelFormat() will return null.

I hope that this helps you, please get back in touch if you have any further questions.

Thanks,

Kai.


#5

hi Kai,

Thank you for your reply. This is the way i set the date format in Android, just sharing it with shinobi forum.

  SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd,H:mm”);

xAxis.setLabelFormat(sdf);

Regards,

Victor


#6

Hello Victor,

Thank you for sharing this and contributing to the community.

Kind regards,

Kai.