io.github.ishaileshmishra.Constants Maven / Gradle / Ivy
package io.github.ishaileshmishra;
import org.json.simple.JSONObject;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
/**
* Constants class.
*
* @author shaileshmishra
* @version $Id: $Id
*/
public class Constants {
/** Constant SDK_VERSION="v2.0.0"
*/
public static final String SDK_VERSION = "v2.0.0";
/** Constant SCHEMA="https://"
*/
public static String SCHEMA = "https://";
/** Constant HOST="cdn.contentstack.io"
*/
public static String HOST = "cdn.contentstack.io";
/**
* processParams.
*
* @param params a {@link org.json.simple.JSONObject} object
* @return a {@link org.json.simple.JSONObject} object
*/
public static JSONObject processParams(JSONObject params) {
if (params == null) {
params = new JSONObject();
}
Set keys = params.keySet();
for (String kay : keys) {
Object value = params.get(kay);
params.put(keys.toString(), value);
}
return params;
}
/**
* convertUTCToISO.
*
* @param date a {@link java.util.Date} object
* @return a {@link java.lang.String} object
*/
public static String convertUTCToISO(Date date) {
final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat dateFormat = new SimpleDateFormat(PATTERN, Locale.US);
dateFormat.setTimeZone(tz);
return dateFormat.format(date);
}
}