title: Android UTC date string to local date
body: <p>I'm having trouble converting a UTC date string to local date string in Android. Example in case is, 
  I've input UTC date string as <code>2018-02-28T02:42:41Z</code></p>
  
  <p>I'm in PST timezone but when I tried to convert to local timezone it doesn't change. I get <code>February 28, 2018 02:42 AM</code> which is incorrect.</p>
  
  <pre><code>public static String convertUTCtoLocalTime(String utcDateString) throws Exception{
  
      SimpleDateFormat dateFormatter;
  
      //create a new Date object using the UTC timezone
      Log.v(TAG, "Input utc date:" + utcDateString);
      dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
      dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
      Date utcDate = dateFormatter.parse(utcDateString);
  
      //Convert the UTC date to Local timezone
      dateFormatter = new SimpleDateFormat("MMMM dd, yyyy hh:mm a");
      dateFormatter.setTimeZone(TimeZone.getDefault());
      String formattedDate = dateFormatter.format(utcDate);
      Log.v(TAG, "convertUTCtoLocalTime: local time:" + formattedDate);
  
      return lv_dateFormateInLocalTimeZone;
  }
  </code></pre>
  
  <p>I don't fully understand the difference but similar conversion works in "swift" as shown below,</p>
  
  <pre><code>    static func utcDateToLocal(utcdate: String) -&gt; String {
        let dateFormatter = DateFormatter()
  
        dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" //Input Format 2018-02-28T02:42:41Z
        dateFormatter.timeZone = NSTimeZone(name: "UTC")! as TimeZone
        let UTCDate = dateFormatter.date(from: utcdate)
  
        dateFormatter.dateFormat = "MMMM dd, yyyy hh:mm a" // Output Format
        dateFormatter.timeZone = TimeZone.current
        let UTCToCurrentFormat = dateFormatter.string(from: UTCDate!)
        return UTCToCurrentFormat
    }
  </code></pre>
  
  <p>Swift example gives me out "February 27, 2018 06:42 PM" which is the correct one.</p>
  
  <p>Swift is using v3.x and </p>
  
  <p>Android is, Studio 3.1.1
  Build #AI-173.4697961, built on April 3, 2018
  JRE: 1.8.0_152-release-1024-b01 x86_64
  JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  Mac OS X 10.13.4</p>
  
  <p>I'm running both examples on the same machine.
  Any hints to solve issue on Android would be really useful.</p>