Skip to content

Instantly share code, notes, and snippets.

@krishnanraman
Created May 24, 2016 21:52
Show Gist options
  • Save krishnanraman/d5ad0f5bfd92735dc336dd4875e404cc to your computer and use it in GitHub Desktop.
Save krishnanraman/d5ad0f5bfd92735dc336dd4875e404cc to your computer and use it in GitHub Desktop.
get prev day
Given a date like 2015-12-31, obtain 2015-12-30
*/
def getPreviousDay(mydate:String):String = {
val fmt = new SimpleDateFormat("yyyy-MM-dd")
val date = fmt.parse(mydate)
val cal = Calendar.getInstance
cal.setTime(date)
cal.add(Calendar.DAY_OF_MONTH,-1)
fmt.format(cal.getTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment