java - Convert string to hex -
i have update date , time of time clock in dynamic way. not able convert string format accepted variable char (not char array).
is there way?
thus that's there works! not dynamic ...
char year = 0x0e; char month = 0x0a; char day = 0x0a; char hr = 0x0a; char min = 0x0a; char sec = 0x0a; byte[] date_hour = new byte[]{(byte) 0xfe, (byte) 0x82, (byte) 0x71, (byte) 0x00, (byte) 0x0b, (byte) 0x01, (byte) 0x00, (byte) 0x07, (byte) year, (byte) month, (byte) day, (byte) hour, (byte) min, (byte) sec, (byte) 0x0a, (byte) 0x17, (byte) 0x0e, (byte) 0x0a, (byte) 0x17}; out.write(date_hour);
i wanted like:
public string getyear() { homecoming year; } //gets... char year = getyear(); char month = getmont(); char day = getday(); char hr = gethour(); char min = getmin(); char sec = getsec(); byte[] date_hour = new byte[]{(byte) 0xfe, (byte) 0x82, (byte) 0x71, (byte) 0x00, (byte) 0x0b, (byte) 0x01, (byte) 0x00, (byte) 0x07, (byte) year, (byte) month, (byte) day, (byte) hour, (byte) min, (byte) sec, (byte) 0x0a, (byte) 0x17, (byte) 0x0e, (byte) 0x0a, (byte) 0x17}; out.write(date_hour);
i tried: hex-encoded string byte array how convert/parse string char in java?
sorry bad english language ... thanks!
if want convert string char, can this:
suppose str variable name of string.
char ch = str.tochararray()[0];
or, can use:
char ch = str.charat(0);
both of these store first character (which character in case string character) of string str int character ch.
java string char hex byte
No comments:
Post a Comment