Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9318959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:51+00:00 2026-06-19T03:15:51+00:00

Here i have one String and i converted this string to long and than

  • 0

Here i have one String and i converted this string to long and than this long value converted into bytes. This byte array length is 6.

    final byte[] tagBytes = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN)
            .putLong(Long.parseLong("02201156116")).array();
    System.arraycopy(tagBytes, 0, tag, 0, 6);
    Log.d("TAG", "TAG in bytes "+Arrays.toString(tag));

Here i got output like this [52, 84, 49, -125, 0, 0]

Now i want to convert this output bytes in String as like before "02201156116"

So here i have to first order bytes in BIG_ENDIAN first and then wrap Bytes and get long value from it.
But Here i am Surprised why it is not work for

ByteBuffer.wrap(tempDateBytes).order(ByteOrder.BIG_ENDIAN).getLong() 

this and its work for

ByteBuffer.wrap(tempDateBytes).order(ByteOrder.LITTLE_ENDIAN).getLong() this, By d way we have to Apply BIG_ENDIAN becuase when we convert long to bytes we used LITTLE_ENDIAN. So i think we have to use here BIG_ENDIAN. but its not works for BIG_ENDIAN, its works for LITTLE_ENDIAN.

This code i used to convert [52, 84, 49, -125, 0, 0] to 02201156116

    long time,time1;
    final byte[] tempDateBytes = new byte[8];
    System.arraycopy(tagBytes, 0, tempDateBytes, 0, 6);
    time1 = ByteBuffer.wrap(tempDateBytes).order(ByteOrder.BIG_ENDIAN).getLong();
    time = ByteBuffer.wrap(tempDateBytes).order(ByteOrder.LITTLE_ENDIAN).getLong();
    Log.d("TAG", "Orignal TAG "+time);
    Log.d("TAG", "BAD TAG  "+time1);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:15:52+00:00Added an answer on June 19, 2026 at 3:15 am

    Think about it in terms of short. Let’s say we encode the value 258:

    258 = 256 + 2 = 0x0102
    

    Now, if we put this in an array, we must decide which byte we put at index 0. We can do

    { 0x01, 0x02 }
    

    or

    { 0x02, 0x01 }
    

    No order is per se better than the other, but the crucial point is to remember which order we used, when we ever want do decode the array and want to get the value 258 back.

    This is the purpose of LITTLE_ENDIAN and BIG_ENDIAN. On encoding, it tells the byte order to use. On decoding, it tells the byte order we used when we encoded.

    Hence, to not mess things up, be sure to use the same byte order on encoding and decoding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the scenario, I have a WCF service call that takes one string
Here is the situation: You have one long-running calculation running in a background thread.
I have one String like 01030920316 . when i am going to convert this
Here is the problem: I have one giant string of xml data stored in
Here is my situation: I have one table that contains a list of drugs
I have one problem with parsing *.docx document with OpenXML (C#). So, here's my
so here's the problem I have one form, it outputs search results after submit,
here is the problem. I have one PC using VS2008 (SP1 ) and another
Here i want to do UDP Socket programming in C. I have one device
Ok, so here's what I want to do, preferably with jQuery 1.4.2: Have one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.