Here you can find the source of getUserToServerDateTimeString(TimeZone timeZone, int dateFormat, int timeFormat, String date)
Parameter | Description |
---|---|
date | Description of the Parameter |
timeZone | Description of the Parameter |
dateFormat | Description of the Parameter |
timeFormat | Description of the Parameter |
public static String getUserToServerDateTimeString(TimeZone timeZone, int dateFormat, int timeFormat, String date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.util.Locale; import java.util.TimeZone; public class Main { /**/* w w w .j a va2 s. c om*/ * Gets the dateString attribute of the DateUtils object * * @param date Description of the Parameter * @param timeZone Description of the Parameter * @param dateFormat Description of the Parameter * @param timeFormat Description of the Parameter * @return The dateString value */ public static String getUserToServerDateTimeString(TimeZone timeZone, int dateFormat, int timeFormat, String date) { return getUserToServerDateTimeString(timeZone, dateFormat, timeFormat, date, Locale.getDefault()); } /** * Gets the userToServerDateTimeString attribute of the DateUtils class * * @param timeZone Description of the Parameter * @param dateFormat Description of the Parameter * @param timeFormat Description of the Parameter * @param date Description of the Parameter * @param locale Description of the Parameter * @return The userToServerDateTimeString value */ public static String getUserToServerDateTimeString(TimeZone timeZone, int dateFormat, int timeFormat, String date, Locale locale) { String convertedDate = null; try { DateFormat localeFormatter = DateFormat.getDateInstance(dateFormat, locale); if (timeZone != null) { localeFormatter.setTimeZone(timeZone); } DateFormat serverFormatter = DateFormat.getDateTimeInstance(dateFormat, timeFormat); //convertedDate = serverFormatter.format(localeFormatter.parse(date)); convertedDate = serverFormatter.format(new java.util.Date(localeFormatter.parse(date).getTime())); } catch (Exception e) { if (date != null && !"".equals(date)) { System.err.println("EXCEPTION: DateUtils-> Timestamp " + e); } } return convertedDate; } }