How to convert “MM-dd-yyyy hh:mm” String date format to GMT format?

DiDzI

New Member
My Date format is like as "MM-dd-yyyy hh:mm" its not current date ,I have to send this date to server but before send it need to change this date to GMT format but when I change by following code:\[code\]private String[] DateConvertor(String datevalue) { String date_value[] = null; String strGMTFormat = null; SimpleDateFormat objFormat,objFormat1; Calendar objCalendar; Date objdate1,objdate2; if(!datevalue.equals("")) { try { //Specify your format objFormat1 = new SimpleDateFormat("MM-dd-yyyy,HH:mm"); objFormat1.setTimeZone(Calendar.getInstance().getTimeZone()); objFormat = new SimpleDateFormat("MM-dd-yyyy,HH:mm"); objFormat.setTimeZone(TimeZone.getTimeZone("GMT")); //Convert into GMT format //objFormat.setTimeZone(TimeZone.getDefault());//); objdate1=objFormat1.parse(datevalue); // //objdate2=objFormat.parse(datevalue); //objFormat.setCalendar(objCalendar); strGMTFormat = objFormat.format(objdate1.getTime()); //strGMTFormat = objFormat.format(objdate1.getTime()); //strGMTFormat=objdate1.toString(); if(strGMTFormat!=null && !strGMTFormat.equals("")) date_value = http://stackoverflow.com/questions/15893159/strGMTFormat.split(","); } catch (Exception e) { e.printStackTrace(); e.toString(); } finally { objFormat = null; objCalendar = null; } } return date_value; }\[/code\]its not change in required format ,I have tried by above code first try to get current timeZone and after that try change string date into that timezone after that convert GMT.anyone guide me.thanks in advance.
 
Top