-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate_formate.java
More file actions
23 lines (16 loc) · 900 Bytes
/
date_formate.java
File metadata and controls
23 lines (16 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// date formate
private SimpleDateFormat dateFormat = new SimpleDateFormat("d,MMM, yyyy", Locale.ENGLISH);
// bangla date formate --> it will remove hh:mm:ss --> if you don't to do that, hh:mm:ss to the convert line to bangla locale date formate.
private String formatDateInEnglishAndBengali(String dateString) {
try {
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Date date = originalFormat.parse(dateString);
SimpleDateFormat bengaliFormat = new SimpleDateFormat("yyyy-MM-dd", new Locale("bn", "BD")); // Bengali locale
String bengaliDate = bengaliFormat.format(date);
return bengaliDate;
} catch (ParseException e) {
e.printStackTrace();
// Return the original string in case of an error
return dateString;
}
}