title: Using java.time classes in older Android, such as DayOfWeek
body: <p>The application I'm working on is related to the weekly calendar.</p>
  <p>I want to fetch the days of the week. The code below for this is fully working. But I have to lower the API level of the project to 26 -&gt; 24. Thus, some codes become inoperable at API 24 level.</p>
  <p>How can I go about this in an alternative way?</p>
  <p><strong>My Code:</strong></p>
  <pre><code>fun daysOfWeekFromLocale(): Array&lt;DayOfWeek&gt; {
  
  val firstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek
  var daysOfWeek = DayOfWeek.values()
  
  if (firstDayOfWeek != DayOfWeek.MONDAY) {
      val rhs = daysOfWeek.sliceArray(firstDayOfWeek.ordinal..daysOfWeek.indices.last)
      val lhs = daysOfWeek.sliceArray(0 until firstDayOfWeek.ordinal)
      daysOfWeek = rhs + lhs
  }
  
  return daysOfWeek
  }
  </code></pre>
  <p><strong>Android studio's Red Lines:</strong></p>
  <p><a href="https://i.stack.imgur.com/xYwJg.png" rel="nofollow noreferrer">Function Image</a></p>
  <p>(In all cases this function should return the same value. -- Array&lt; DayOfWeek &gt; )</p>