package com.nmakademija.nmaakademija.utils;


import android.support.annotation.Nullable;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class DateUtils {

    private static final String DATE_FORMAT_PATTERN_TZ = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    private static final String TIME_FORMAT_PATTERN = "HH:mm";

    private static final SimpleDateFormat TIME_FORMAT =
            new SimpleDateFormat(TIME_FORMAT_PATTERN, Locale.US);

    private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT_PATTERN_TZ,
            Locale.US);

    static {
        DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
        TIME_FORMAT.setTimeZone(TimeZone.getDefault());
    }

    @Nullable
    public static Date parseTZDate(String pattern) {
        try {
            return DATE_FORMAT.parse(pattern);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    @Nullable
    public static String formatTime(@Nullable Date date) {
        if (date == null) {
            return null;
        }

        return TIME_FORMAT.format(date);
    }


}

@@ -428,16 +428,28 @@
 c final 
+ThreadLocal%3C
 SimpleDa
@@ -456,16 +456,17 @@
 teFormat
+%3E
  TIME_FO
@@ -471,28 +471,143 @@
 FORMAT =
-%0A           
+ new ThreadLocal%3CSimpleDateFormat%3E() %7B%0A        @Override%0A        protected SimpleDateFormat initialValue() %7B%0A            return
  new Sim
@@ -648,24 +648,41 @@
  Locale.US);
+%0A        %7D%0A    %7D;
 %0A%0A    privat
@@ -690,16 +690,34 @@
  static 
+final ThreadLocal%3C
 SimpleDa
@@ -724,16 +724,17 @@
 teFormat
+%3E
  DATE_FO
@@ -735,24 +735,151 @@
 ATE_FORMAT =
+ new ThreadLocal%3CSimpleDateFormat%3E() %7B%0A        @Override%0A        protected SimpleDateFormat initialValue() %7B%0A            return
  new SimpleD
@@ -911,16 +911,28 @@
 TERN_TZ,
+ Locale.US);
 %0A       
@@ -936,22 +936,15 @@
     
+%7D%0A
     
-Locale.US)
+%7D
 ;%0A%0A 
@@ -967,32 +967,38 @@
     DATE_FORMAT.
+get().
 setTimeZone(Time
@@ -1043,16 +1043,22 @@
 _FORMAT.
+get().
 setTimeZ
@@ -1204,16 +1204,22 @@
 _FORMAT.
+get().
 parse(pa
@@ -1502,16 +1502,22 @@
 _FORMAT.
+get().
 format(d

use ThreadLocal