Linked Questions

Popular Questions

I have to parse the following String into a more readable date format.

String date = "20190112151605.0Z";

However, I've never encountered the Z before. I know it has to do with the time zone but when I try to use my usual code I get a java.lang.NumberFormatException.

My code is as follows:

 String whenChanged = "20190112151605.0Z";  

 long DIFF_NET_JAVA_FOR_DATE_AND_TIMES = 11644473600000L;
 long adDate1 = Long.parseLong(whenChanged);
 long adLongDate1 = ( adDate1  / 10000 ) - DIFF_NET_JAVA_FOR_DATE_AND_TIMES;
 Date lastLogonDate1 = new Date(adLongDate1);
 String format2 = new SimpleDateFormat("MM/dd/yyyy 
 HH:mma'Z'").format(lastLogonDate1);

Any help would be great. Thanks

Related Questions