Convert hexadecimal value to Date in core Java
<p>My program needs to convert a Hexadecimal input to a Date using Java.
I am getting below inputs of hexadecimal types :
1) 17F5AD8A 2) 182eb09b 3) 182eb09b 4) 182eb43d etc.</p>

<p>The decimal values for above hexadecimal inputs like 401976714 , 405713051 etc.</p>

<p>I tried several ways of converting decimal to Date but I am getting year as 1970 OR 1982.</p>

<p>My input should provide the year as 2012 with respective dd,mm,hh,mm,ss values.</p>

<p>I need to convert it into UTC format. </p>

<p>Here is my current code:</p>

<pre><code>import java.sql.Date; 
import java.text.SimpleDateFormat; 

public class HexToDate { 
    public static void main(String args[]) { 
        String hexVal = "17F5AD8A"; 
        String decimalVal = Long.parseLong(,16); 
        SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); 
        Date d = f.format((decimalVal)*(1000L)); 
    } 
}
</code></pre>
