i found many functions to convert from utc to local time but i didnot find how to convert from local to utc ?
this is used from utc to local ,how to edit to get utc from local ?
public static String timezoneAwareDate(String date){
// create simpledateformat for UTC dates in database
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date output;
// parse time
try{
output = simpleDateFormat.parse(date);
}catch (Exception e){
// return current time
output = new Date();
}
return output.toString();
}