Here is what I need to do:
I need to convert date and time in hex code for writing it on IOT device. Here is my code
private String getDateTimeToHexa() {
Calendar mCalendar = Calendar.getInstance();
TimeZone gmtTime = TimeZone.getTimeZone(TimeZone.getDefault().getDisplayName());
mCalendar.setTimeZone(gmtTime);
final Date date = mCalendar.getTime();
return Long.toHexString(date.getTime());
}
It is returning 11 digits hex code I need 8 digits, just like date and time in hex is 47C7EDE0 for this date 12:34:56 29/Feb/2008