user3965683
user3965683

Reputation: 25

Convert int to bytes

I had a calendar widget and passed the values to another activity through bundle. How can I, after getting values from bundle, convert "year","month","day" into bytes?

    int year = extras.getInt("year");
    int day = extras.getInt("day");
    int month = extras.getInt("month");

Upvotes: 0

Views: 1740

Answers (1)

Daud Arfin
Daud Arfin

Reputation: 2499

You can convert your int to bytes by using a ByteBuffer.

byte[] bytes = ByteBuffer.allocate(4).putInt(year).array();

Upvotes: 1

Related Questions