Q:

What does lowercase "month" mean in Scala?

I found a very strange problem in Scala. I was trying to get the last day of last month. The following worksheet showed the correct result (in Scala, Month starts from 0(Jan), so Mar. is 2).

However, if I comment out the last line on the left, the results are as the follows:

What I did is just to assign the lastMonth variable to month. And the lastMonth is changed to 3!
Where did I do wrong?
Here is the code snippet:
import java.util.{Calendar, GregorianCalendar} // Get current time and the last date of last month

val now = Calendar.getInstance()
// test code
//now.set(Calendar.MONTH, Calendar.DECEMBER)

// get current year
val currYear = now.get(Calendar.YEAR)
// get current month, JANUARY is 0
val currMonth = now.get(Calendar.MONTH)

// back to last month
val lastMonthCalendar = now
// if this month is Dec, the YEAR would be automatically deducted by 1
lastMonthCalendar.add(Calendar.MONTH, -1)
lastMonthCalendar.getTime
val lastMonth = lastMonthCalendar.get(Calendar.MONTH)
val numDaysOfLastMonth = lastMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH)
lastMonthCalendar.set(Calendar.DATE, numDaysOfLastMonth)
lastMonthCalendar.getTime

var year = lastMonthCalendar.get(Calendar.YEAR)
var month = lastMonth

A:

get the last day of last month

Is this what you want? 
scala> import java.time.LocalDate
import java.time.LocalDate

scala>  LocalDate.now().withDayOfMonth(1).minusDays(1)
res1: java.time.LocalDate = 2018-03-31

scala> res1.getDayOfMonth
res2: Int = 31

scala> res1.getMonth
res3: java.time.Month = MARCH

scala> res1.getMonthValue
res4: Int = 3

