So I have a calendar that I need to set a specific date to..
Date date = TKDateUtils.parseDate("Jun 02, 2016 05:10:30 pm");
Calendar next = Calendar.getInstance();
next.setTime(date);
and I log them here to see the output:
Log.i("MainActivity", date.toString());
Log.i("MainActivity", date.getTime() + "");
Output:
06-02 20:21:29.245 1915-1915/com.cyscorpions.timekeeper I/MainActivity: Thu Jun 02 17:10:30 EDT 2016
06-02 20:21:29.245 1915-1915/com.cyscorpions.timekeeper I/MainActivity: 1464901830000
So I convert the getTime
from millis to Date and this is the output:
So the Date
is set to June 2, 2016 17:10:30
but the getTime()
is set to the exact day after that date.
Am I doing something wrong here?
Here is how I parse the date:
public static Date parseDate(@NonNull String dateString) {
try {
mDateFormat = new SimpleDateFormat("MMM dd, yyyy h:mm:ss a");
return mDateFormat.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
The problem was on Genymotion's
TimeZone
all along. It is set to a different timezone from my location.