- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Parse and format to hexadecimal in Java
To parse and format to hexadecimal in Java, we have used the BigInteger class. The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.
In the below example, we have taken BigInteger and created an object. With that, some values have been set by us in the arguments as the hexadecimal and the radix i.e. 16 for hexadecimal.
BigInteger bi = new BigInteger("2ef", 16);
Let us see an example.
Example
import java.math.*; public class Demo { public static void main( String args[] ) { BigInteger bi = new BigInteger("2ef", 16); String s = bi.toString(16); System.out.println(s); } }
Output
2ef
- Related Articles
- Format and Parse Date in Java
- Parse hexadecimal string to create BigInteger in Java
- Parse and format a number to octal in Java
- Parse and format a number to decimal in Java
- Java Program to Parse and Format a Number into Binary
- Java Program to parse Time using custom format
- Parse and format to arbitrary radix
- How to Convert a String to Hexadecimal and vice versa format in java?
- Java Program to parse string date value with default format
- How to format hexadecimal Number in JavaScript?
- C# Hexadecimal ("X") Format Specifier
- C# Program to write a number in hexadecimal format
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- Convert Hexadecimal to Octal in Java?
- Java Program to parse date and time

Advertisements