0

I'm using the latest Joda-Time 2.6 in my application. My Joda library is able to display month based on a language is set on device. However, all my digits such as day_of_month, hour and minute displays in English format rather than local format.

Since my application is using in different countries I need all date/time strings displays in local language formats.

Any idea how can I fix my issue? Thanks.

private String getFormattedDate(Calendar calendar) {
        Date date = calendar.getTime(); // out: Dec 9, 2014

        DateTime dt = new DateTime(date);
        StringBuilder sb = new StringBuilder(3);
        sb.append(dt.monthOfYear().getAsShortText());
        sb.append(" ");
        sb.append(dt.dayOfMonth().getAsShortText());

//        Log.d(TAG, sb.toString());
        return sb.toString();
    }

    private String getFormattedTime(Calendar calendar) {
        Date date = calendar.getTime();
        Log.d(TAG, DateFormat.getTimeInstance(DateFormat.SHORT).format(date));

        DateTime dt = new DateTime(date);
        StringBuilder sb = new StringBuilder(3);
        sb.append(dt.getHourOfDay());
        sb.append(":");
        sb.append(dt.getMinuteOfHour());

//        Log.d(TAG, sb.toString());
        return sb.toString();
    }
Hesam
  • 52,260
  • 74
  • 224
  • 365
  • Why should you care about this? I've never seen a language that use its own digits for writing time even if it has. For example in Japanese sometimes dates are written in Chinese characters but never is time – phuclv Dec 09 '14 at 09:36
  • @LưuVĩnhPhúc, The requirement is like this. I fixed the issue in this way http://stackoverflow.com/a/27371005/513413 – Hesam Dec 09 '14 at 09:58
  • Yes I know, but if that locale uses a different digit system it'll automatically be used so there should be no problem. For example for Japanese there are 2 different locales ja and ja_JP which will display the values in different formats – phuclv Dec 09 '14 at 10:41

0 Answers0