I am trying to convert an Arabic Time to Englist Time can anyone help me on this.
Example :- The Arabic Time is 12:30 صباحاً
The English Time should be 12.30 AM
I am trying to convert an Arabic Time to Englist Time can anyone help me on this.
Example :- The Arabic Time is 12:30 صباحاً
The English Time should be 12.30 AM
You may use a DateFormat
with an arabic Locale
to parse the original String
to a Date
, then a DateFormat
with Locale.ENGLISH
to convert to an english String
:
DateFormat formatArabic = new SimpleDateFormat("hh:mm aa", new Locale("ar", "SA"));
DateFormat formatEnglish = new SimpleDateFormat("hh:mm aa", Locale.ENGLISH);
try {
Date date = formatArabic.parse("12:30 صباحاً");
System.out.println(formatEnglish.format(date));
} catch (ParseException e) {
e.printStackTrace();
}