I'm trying to manually enter a forum user into an smf database but can't seem to figure out how to get the current date in the proper format, which I found out is something called "packed byte".
can anyone point me to some info to help out?
If I interpreted the spec you linked in comments correctly - you can use a combination of String formatting and parsing to get what you need. I chose to use String formatting because although the output expected is a base-16 number, it appears to encode values as base-10 values within the base-16 number.
Calendar toPack = Calendar.getInstance();
int century = (toPack.get(Calendar.YEAR) - 1900) / 100;
int year = toPack.get(Calendar.YEAR) % 100;
int dayOfYear = toPack.get(Calendar.DAY_OF_YEAR);
String packedDate = String.format("%02d%02d%03dC", century, year, dayOfYear);
int packed = Integer.parseInt(packedDate, 16);
System.out.printf("0x%x%n", packed);
Output:
0x114238c
According IBM's SFM Wiki the 'byte packed date format' is defined as follows:
Example: Aug. 31. 2014 = 0x01 14 244 C
In Java you could use the
java.util.Calendar
to create a hex string containing all required values and useLong.valueOf(...,16)
to get a number out of it.