Skip to content

Instantly share code, notes, and snippets.

@ppurang
Created December 17, 2012 12:43
Show Gist options
  • Save ppurang/4318018 to your computer and use it in GitHub Desktop.
Save ppurang/4318018 to your computer and use it in GitHub Desktop.
isNotSameDayAndStillBefore ..
import java.util.{Calendar => C}
import C._
def isSameDay(one: C, two: C) = one.get(ERA) == two.get(ERA) && one.get(YEAR) == two.get(YEAR) && one.get(DAY_OF_YEAR) == two.get(DAY_OF_YEAR)
//is the following the same?
def isSameDay2(one: C, two: C) = Math.abs(one.getTimeInMillis - two.getTimeInMillis) < 86400000
def isNotSameDayAndStillBefore(one: C, two: C) = !isSameDay(one, two) && one.before(two)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment