I need to get normal correct time in android application. But every time I run the app, I get wrong hours and wrong minutes. And it is not the incorrect TimeZone. Every time I run the app, the time is different! I've searched through questions here, but haven't found the answer for me. Nothing works with this... Why is it so problematic in java? In c#. for example, you can get time by just writting: var time = DateTime.Now
. How can I get normal correct time? The time zone on my computer is set to UTC +02:00. (Ukraine, Kiev).
My code:
Calendar curTime = new GregorianCalendar();
curTime.setTimeZone(TimeZone.getTimeZone("Ukraine/Kiev"));
DateFormat dateFormat = new SimpleDateFormat("HH:ss");
dateFormat.setCalendar(curTime);
String time = dateFormat.format(curTime.getTime());