Skip to content

Instantly share code, notes, and snippets.

@is
Created October 28, 2012 14:34
Show Gist options
  • Save is/3968764 to your computer and use it in GitHub Desktop.
Save is/3968764 to your computer and use it in GitHub Desktop.
Convert String array to byte[][] in JRuby
tsbegin = Time.gm(2012, 8, 10)
tsend = Time.gm(2012, 10, 30)
tsadd = 3600 * 6
splits = Array.new
while tsbegin < tsend do
splits << tsbegin.strftime("%Y%m%d%H%M").to_java_bytes
tsbegin += tsadd
end
splitkeys = Java::byte[][splits.size].new
for i in 0 .. splits.size - 1 do
splitkeys[i] = splits[i]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment