Skip to content

Instantly share code, notes, and snippets.

@erraggy
Created December 3, 2013 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erraggy/7762215 to your computer and use it in GitHub Desktop.
Save erraggy/7762215 to your computer and use it in GitHub Desktop.
implicit object YearDayConverter extends ByteConverter[YearDay] {
val SPLITTER = "_".r
override def toBytes(t:YearDay) = Bytes.toBytes(t.year.toString + "_" + t.day.toString)
override def fromBytes(bytes:Array[Byte]) = {
val strRep = Bytes.toString(bytes)
val strRepSpl = SPLITTER.split(strRep)
val year = strRepSpl(0).toInt
val day = strRepSpl(1).toInt
YearDay(year,day)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment