Created
December 3, 2013 01:14
-
-
Save erraggy/7762215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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