Calendar.getInstance() returns NullPointerException in ios device?
<p>When I try to get the current time I am using below code. But it shows <code>Null Pointer Exception</code> in Apple device. It is working fine in Android device. </p>

<p>How to solve this exception? What's  wrong in my code?</p>

<pre><code>String hourValue    = "";
String minutesValue = "";
String amPm         = "AM";
Calendar now        = Calendar.getInstance();
int hour            = now.get(Calendar.HOUR_OF_DAY);
int minute          = now.get(Calendar.MINUTE);
int amPmVal         = now.get(Calendar.AM_PM);
if(hour &gt; 12){
    hour = hour -12;
}
if(hour == 0){
    hour = 12;
}
if(amPmVal == 1){
    amPm = "PM";
}
hourValue = hour+"";
minutesValue    = minute+"";                
if(minute &lt; 10){
     minutesValue = "0"+minutesValue;
}
return hourValue+":"+minutesValue+" "+amPm;
</code></pre>