Created
October 19, 2012 03:05
-
-
Save johndemic/3916006 to your computer and use it in GitHub Desktop.
StockQuoteRequest Helper Methods
This file contains hidden or 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
public byte[] toProtocolBufferAsBytes() { | |
return StockQuoteRequestBuffer.newBuilder() | |
.setSymbol(symbol) | |
.setStart(startDate.getTime()) | |
.setEnd(endDate.getTime()).build().toByteArray(); | |
} | |
public static StockQuoteRequest fromProtocolBuffer(StockQuoteRequestBuffer buffer) { | |
StockQuoteRequest request = new StockQuoteRequest(); | |
request.setSymbol(buffer.getSymbol()); | |
request.setStartDate(new Date(buffer.getStart())); | |
request.setEndDate(new Date(buffer.getEnd())); | |
return request; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment