0

I have these values as a Date

dates: java.util.ArrayList  = {java.util.ArrayList@16314}  size = 2
        0 = {java.util.Date@16339} "Thu Mar 19 11:00:00 GMT+02:00 2020"
        1 = {java.util.Date@16340} "Thu Mar 19 12:00:00 GMT+02:00 2020"

My problem is that I need to ignore the Timezone. I need to ignore the +2 difference, and only get the 11:00 and 12:00 hours from them. How can I accomplish this ?! I can't figure it out.

I converted them to a Calendar but I can't manage to convert them to a Calendar object and not have it automatically adjust the time when trying to retrieve it from the Calendar

AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106

2 Answers2

0

You can use DateUtils for this https://developer.android.com/reference/android/text/format/DateUtils.html

Use android.text.format.DateUtils.getRelativeTimeSpanString

It returns a string describing 'time' as a time relative to 'now'.

Adi
  • 31
  • 3
0
DateFormat df = new SimpleDateFormat("MMM dd, yyyy K:mm:ss,SSS a z", Locale.ENGLISH);
long diff = TimeZone.getDefault().getRawOffset() - df.getTimeZone().getRawOffset();
inputDate = new Date(ynputDate .getTime() - diff);

inputDate is your date

Destroyer
  • 785
  • 8
  • 20