0
我有字符串中的小時和分鐘,我想將它轉換爲UTC時區下面是我的代碼,但我得到了錯誤的小時和分鐘請幫助我....謝謝在java中將字符串時間和分鐘轉換爲UTC
Calendar time = Calendar.getInstance(TimeZone.getTimeZone(Utils.merchantTimeZone));
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss z");
System.out.println("Raw time====" + rawTime);
time.set(Calendar.HOUR_OF_DAY, Integer.parseInt(rawTime.substring(0, 2)));
time.set(Calendar.MINUTE, Integer.parseInt(rawTime.substring(2,4)));
sdf.format(time);
rawTime = time.get(Calendar.HOUR) +""+ time.get(Calendar.MINUTE);
你想要什麼,你會得到什麼? –
提供錯誤日誌和輸入值 –
檢查joda-time android庫,它有很多準備好的函數來轉換日期和時間.... https://github.com/dlew/joda-time-android –