Search code examples
androidandroid-framework

DateFormat error in android


I'm using DateFormat.format("EEEE d MMMM", new Date()) ,for arabic it displaying as : الثلاثاء 29 ٥

can anyone tell me how can i get that 29 in the specific locale(which was set) numeral or least how can i ignore the current locale set and display date in English only for all locales.


Solution

  • I finally managed to get the date in required format whatever the locale may be,the code goes as:

    SimpleDateFormat sf = new SimpleDateFormat("EEEE dd MMMM",new Locale("en"));
    textViewID.setText(sf.format(new Date()).toString());
    

    This will display date as

    Wednesday 29 August

    dont forget to add

    import java.text.SimpleDateFormat;