Skip to content

Instantly share code, notes, and snippets.

@auramo
Created March 24, 2014 19:04
Show Gist options
  • Save auramo/9746874 to your computer and use it in GitHub Desktop.
Save auramo/9746874 to your computer and use it in GitHub Desktop.
private def getMonthLetterForWeek(yearAndWeek: YearAndWeek): String = {
val day = yearAndWeek.firstDay
val currentDayCalendar = day.toCalendar(Locale.getDefault())
val weekOfMonth = currentDayCalendar.get(Calendar.WEEK_OF_MONTH)
if (weekOfMonth < 5) {
val shortMonths = new DateFormatSymbols(Locale.ENGLISH).getShortMonths
val weekOfMonthIndex = weekOfMonth - 2
if (weekOfMonthIndex < 0) "" else (shortMonths(day.getMonthOfYear - 1)(weekOfMonthIndex) + "").toUpperCase
} else { "" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment