title: Converting seconds to time of day
body: <p>I have an app on iOS and am working on porting over to android. I am having an issue with handling the time.</p>
  
  <p>On iOS I store points of time using:</p>
  
  <pre><code>Int(NSDate().timeIntervalSince1970-0.5)
  </code></pre>
  
  <p>and Convert it to HH:MM:SS using:</p>
  
  <pre><code>private let dateFormatter = DateFormatter()
  dateFormatter.dateFormat = "HH:mm:ss"
  return dateFormatter.string(from: Date(timeIntervalSince1970: value))
  </code></pre>
  
  <p>On Android(Kotlin) to store the point of time I use: <code>System.currentTimeMillis()/1000</code></p>
  
  <p>And for conversion:</p>
  
  <pre><code>LocalTime.MIN.plus(Duration.ofSeconds(xVal)).toString())
  </code></pre>
  
  <p>The issue is that the value after being converted is 6 hours ahead(could be more or less but I only look at the HH:MM:SS). As far as I can tell, the way that I get the time on android is correct and I think the issue lies in when I am converting it. I have looked around for more methods of converting time since an an interval to time of day but I could not get it to work. Most posts are just converting seconds to HH:MM:SS and so those are right out of the question. What would the equivalent to my iOS code be?</p>
  
  <p><strong>EDIT</strong>
  I've also tried using this method to convert it still is 6 hours off even though I am giving it a timezone:</p>
  
  <pre><code>    val cal = Calendar.getInstance()
      cal.timeInMillis = xVal * 1000L
      cal.timeZone = TimeZone.getTimeZone(TimeZone.getDefault().displayName)
      Log.i("This is the cal value",cal.get(Calendar.HOUR_OF_DAY).toString())
  </code></pre>