title: How to resolve side effect rising from LocalDate in tests (scala)?
body: <p>I have a function where I convert time in millis to a <code>LocalDate</code> object:</p>
  <pre><code>def convertToLocalDateTimeViaInstant(dateToConvert: java.util.Date): java.time.LocalDate =
      dateToConvert.toInstant.atZone(ZoneId.systemDefault).toLocalDate
  </code></pre>
  <p>And I have a unit test for this function as follows:</p>
  <pre><code> &quot;convertToLocalDateTimeViaInstant&quot; should {
      &quot;return the correct LocalDate instance&quot; in new SAMLServiceTestEnv() {
        val timeInMillis: Long = 1349333576093L // Date is Thu Oct 04 2012 06:52:56 UTC in millis
        val someDate = new Date(timeInMillis) 
        val resultDate: LocalDate = samlServiceImpl.convertToLocalDateTimeViaInstant(someDate)
        
        resultDate.getYear mustEqual 2012
        resultDate.getMonth mustEqual java.time.Month.OCTOBER
        resultDate.getDayOfMonth mustEqual 4
      }
    }
  </code></pre>
  <p>When I run this test just by itself or the whole file, this test makes the correct assertions. The value <code>1349333576093L</code> corresponds to <code>Thu Oct 04 2012 06:52:56</code> UTC and <code>Wed Oct 03 2012 23:52:56</code> PST (San Francisco time).</p>
  <p>However, when I run ALL the unit tests in the project, I observe a failure in this test. The <code>resultDate.getDayOfMonth mustEqual 4</code> assertion fails stating <code>4 is not equal to 3</code>. I'm surprised to see this as the function clearly considers UTC time when run by itself but somehow observes local time when run all together? What am I doing wrong here?</p>