- I'm learning Android a simple screen with user Information like name,Date of Birth and so on.
- All are Text View and Edit Text.
- In my pojo Date of Birth datatype is String.
- When I enter date and try to get the date it is showing as some long number I this it is date and time in milliseconds.
- Can any one help me to solve this.
Asked
Active
Viewed 93 times
0

Rakesh
- 41
- 1
- 6
-
1Put your code, please. – Oscar LT Mar 21 '16 at 12:42
-
1@Rakesh Refer here:- http://coderzpassion.com/android-working-date/ – Jagjit Singh Mar 21 '16 at 12:43
-
see this link-http://stackoverflow.com/questions/13667966/how-to-get-date-from-milliseconds-in-android – sumit singh Mar 21 '16 at 12:46
-
code please .show what you have done . – Sagar Nayak Mar 21 '16 at 13:00
2 Answers
0
If i understand your problem.. Try this...
Date d1 = new Date();
d1.setTime(time_in_milliseconds);
Calendar cal = Calendar.getInstance();
cal.setTime(d1);
And then you can get day,month, year..
int number_of_day = cal.get(Calendar.DAY_OF_MONTH)

Nikos Mitropoulos
- 163
- 10
0
Check this :
public Date getDateByFormat(String time, String format) {
if (time == null || "".equals(time)) return null;
try {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.ENGLISH);
return sdf.parse(time);
} catch (ParseException e) {
Log.d(Constants.TAG, "Could not parse date: " + time + " Due to: " + e.getMessage());
}
return null;
}
here format is your date string format. Like "yyyy-MM-dd HH:mm:ss"

Sayem
- 4,891
- 3
- 28
- 43