title: long integers, and nscala_time
body: <p>My top-level problem is to take some time values that I get from a stream as 64-bit nanosecond Unix times, in Scala, using nscala_time (which wants milliseconds --- should be easy enough).  Having hit some problems with that, I started experimenting, and found that it was readily converting Long to Int, and I can't understand the rules for that.  Having got a number that I can pass to nscala_time, I then found that the number I chose doesn't convert to a valid date-time string.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>  val constructedTimeOne:Long = (((((((3) * 24) + 12) * 60) + 34) * 60 + 56) * 1000)
    val constructedDateOne = new DateTime(constructedTimeOne)
    val constructedStringOne = constructedDateOne.toString("YYYY-MM-DD HH:MM:SS")
    println(s"constructedTime $constructedTimeOne converts to $constructedStringOne")
  
    val constructedTimeTwo:Long = constructedTimeOne + (31 * 24 * 60 * 60 * 1000).asInstanceOf[Long]
    val constructedDateTwo = new DateTime(constructedTimeTwo)
    val constructedStringTwo = constructedDateTwo.toString("YYYY-MM-DD HH:MM:SS")
    println(s"constructedTime $constructedTimeTwo converts to $constructedStringTwo")
  
    val constructedTimeThree:Long = (constructedTimeOne + (31.asInstanceOf[Long] * 24 * 60 * 60 * 1000 ))
    val constructedDateThree = new DateTime(constructedTimeThree)
    val constructedStringThree = constructedDateThree.toString("YYYY-MM-DD HH:MM:SS")
    println(s"constructedTime $constructedTimeThree converts to $constructedStringThree")
  </code></pre>
  
  <p>and when I run it, I get this output:</p>
  
  <pre><code>constructedTime 304496000 converts to 1970-01-04 13:01:00
  constructedTime -1312071296 converts to 1969-12-350 20:12:70
  constructedTime 2982896000 converts to 1970-02-35 13:02:00
  </code></pre>
  
  <p>Could someone explain the rules for keeping the value Long?  I can move the "asInstanceOf" to any of the multiplication terms in the third section, and it works OK, but putting it on the outside of that parenthesized expression (as in the second section) doesn't work.</p>
  
  <p>And also, surely the result of converting any number (of time intervals, milliseconds in this case) to a date and time should produce a valid date and time, so what have I done wrong that has produced the date 1970-02-35?</p>