I am not familiar in java and I need to get the current time and present it in a string, for example:
#1:135790246811221:1:*,00000000,UP,060B08,0D1908#
where 060B08 is YYMMDD: GPS date (November 8, 2006). 6 characters, in hexadecimal format.
and 0D1908 - HHMMSS: send time, 6 characters, in hexadecimal format
YYMMDD: send date (13:25:08), 6 characters, in hexadecimal, for example :: represents the value 060B08.
I am trying this code:
Calendar cal = Calendar.getInstance();
Date date = new Date();
String date_str = String.format("%02x%02x%02x", cal.getTime().getYear(), cal.getTime().getMonth(), cal.getTime().getDay());
String hour_str = String.format("%02x%02x%02x", cal.getTime().getHours(), cal.getTime().getMinutes(), cal.getTime().getSeconds());
String content = "#1:" + imei + ":1:*,00000000,UP,"+ date_str.getBytes() +","+ hour_str.getBytes()+"#";
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
buf.writeBytes(content.getBytes(Charset.defaultCharset()));
channel.write(buf);
but erroneously returns:
source
share