Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions hbase-shell/src/main/ruby/hbase/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,9 @@ def parse_column_name(column)
[spec.family, spec.qualifier]
end

def toISO8601(millis)
return java.time.Instant.ofEpochMilli(millis).toString
def toLocalDateTime(millis)
instant = java.time.Instant.ofEpochMilli(millis)
return java.time.LocalDateTime.ofInstant(instant, java.time.ZoneId.systemDefault()).toString
end

# Make a String of the passed kv
Expand All @@ -762,7 +763,7 @@ def to_string(column, kv, maxlength = -1, converter_class = nil, converter = nil
column.start_with?('info:merge')
hri = org.apache.hadoop.hbase.client.RegionInfo.parseFromOrNull(kv.getValueArray,
kv.getValueOffset, kv.getValueLength)
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp),
return format('timestamp=%s, value=%s', toLocalDateTime(kv.getTimestamp),
hri.nil? ? '' : hri.toString)
end
if column == 'info:serverstartcode'
Expand All @@ -773,14 +774,14 @@ def to_string(column, kv, maxlength = -1, converter_class = nil, converter = nil
str_val = org.apache.hadoop.hbase.util.Bytes.toStringBinary(kv.getValueArray,
kv.getValueOffset, kv.getValueLength)
end
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp), str_val)
return format('timestamp=%s, value=%s', toLocalDateTime(kv.getTimestamp), str_val)
end
end

if org.apache.hadoop.hbase.CellUtil.isDelete(kv)
val = "timestamp=#{toISO8601(kv.getTimestamp)}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}"
val = "timestamp=#{toLocalDateTime(kv.getTimestamp)}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}"
else
val = "timestamp=#{toISO8601(kv.getTimestamp)}, value=#{convert(column, kv, converter_class, converter)}"
val = "timestamp=#{toLocalDateTime(kv.getTimestamp)}, value=#{convert(column, kv, converter_class, converter)}"
end
maxlength != -1 ? val[0, maxlength] : val
end
Expand Down