Here you can find the source of toAPITimeString(Date date, String format, String timeZone)
Parameter | Description |
---|---|
date | Date |
format | String |
timeZone | String |
public static String toAPITimeString(Date date, String format, String timeZone)
//package com.java2s; /*/* www . j a va 2 s . c o m*/ Copyright (c) 2013 eBay, Inc. This program is licensed under the terms of the eBay Common Development and Distribution License (CDDL) Version 1.0 (the "License") and any subsequent version thereof released by eBay. The then-current version of the License can be found at http://www.opensource.org/licenses/cddl1.php and in the eBaySDKLicense file that is under the eBay SDK ../docs directory. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; static final String TIME_ZONE = "GMT"; /** * * @param date Date * @param format String * @param timeZone String * @return String */ public static String toAPITimeString(Date date, String format, String timeZone) { SimpleDateFormat dateFormatterAPI = null; dateFormatterAPI = new SimpleDateFormat(format); if (timeZone != null) dateFormatterAPI.setTimeZone(TimeZone.getTimeZone(timeZone)); return dateFormatterAPI.format(date); } /** * Converts date to eBay API date string. * @param date Date * @return String */ public static String toAPITimeString(Date date) { return toAPITimeString(date, DATE_FORMAT, TIME_ZONE); } }