Here you can find the source of localDateTimeToServerTimeString( Date localDateTime, String serverTimeFormat)
public static String localDateTimeToServerTimeString( Date localDateTime, String serverTimeFormat)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { public static String localDateTimeToServerTimeString( Date localDateTime, String serverTimeFormat) { if (localDateTime == null) { return null; }//w ww .j a va 2s . c o m Calendar localCal = Calendar.getInstance(TimeZone .getTimeZone("GMT+00:00")); localCal.setTime(localDateTime); SimpleDateFormat sd = new SimpleDateFormat(serverTimeFormat); sd.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); String serverDateString = sd.format(localCal.getTime()); return serverDateString; } }