I have to update the date and time of a time clock in a dynamic way. I am not able to convert a string to a format accepted by the variable char (not char array).
Is there another way?
Thus that's there works! But not so dynamic ...
char year = 0x0E;
char month = 0x0A;
char day = 0x0A;
char hour = 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 something like:
public String getYear() {
return year;
}
//gets...
char year = getYear();
char month = getMont();
char day = getDay();
char hour = 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 to Byte Array How to convert/parse from String to char in java?
Sorry for my bad english ... Thanks!