Here you can find the source of convertDateToUTC(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String convertDateToUTC(Date date)
//package com.java2s; /*/* w w w .j a v a 2s .c o m*/ * #%L * BroadleafCommerce Common Libraries * %% * Copyright (C) 2009 - 2016 Broadleaf Commerce * %% * Licensed under the Broadleaf Fair Use License Agreement, Version 1.0 * (the "Fair Use License" located at http://license.broadleafcommerce.org/fair_use_license-1.0.txt) * unless the restrictions on use therein are violated and require payment to Broadleaf in which case * the Broadleaf End User License Agreement (EULA), Version 1.1 * (the "Commercial License" located at http://license.broadleafcommerce.org/commercial_license-1.1.txt) * shall apply. * * Alternatively, the Commercial License may be replaced with a mutually agreed upon license (the "Custom License") * between you and Broadleaf Commerce. You may not use this file except in compliance with the applicable license. * #L% */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.s"; /** * Converts the given date to the UTC time zone so that dates can be correctly converted on the client side * * @param date * @return the message */ public static String convertDateToUTC(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat( DEFAULT_DATE_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(date); } }