/**
*
* 根据用户传入时间和用户时区将传入的时间转成服务器对应时间(也可以翻转)<br>
* (功能详细描述)<br>
*
* @author wangyang kf55688
* @see 相关函数,对于重要的函数建议注释
* @since iNOC V200R003C00, 2012-3-7
* @param serZone
* @param curZone
* @param time
* @return
*/ public static String convertServerZoneTime(TimeZone serZone, TimeZone curZone, String time)
{
// 用户时区(本地时区)
TimeZone timeZoneUser = curZone; // 服务器时区(服务器时区)
//此方法用于将对应本地时区的时间转成服务器的时间(用于插入数据库)
//*****************
//如果用于显示到页面则需要将从数据库中取得的时间转成用户对应的时区的时间
//这样只需要交换2个时区的参数
//***************
TimeZone timeZoneServer = serZone; SimpleDateFormat inputFormat = new SimpleDateFormat(Constants.DATATIME_FORMAT);
inputFormat.setTimeZone(timeZoneUser);
Date date = null;
try
{
date = inputFormat.parse(time);
}
catch (ParseException e)
{
}
SimpleDateFormat outputFormat = new SimpleDateFormat(Constants.DATATIME_FORMAT);
outputFormat.setTimeZone(timeZoneServer);
String convertTime = outputFormat.format(date);
return convertTime;
}
*
* 根据用户传入时间和用户时区将传入的时间转成服务器对应时间(也可以翻转)<br>
* (功能详细描述)<br>
*
* @author wangyang kf55688
* @see 相关函数,对于重要的函数建议注释
* @since iNOC V200R003C00, 2012-3-7
* @param serZone
* @param curZone
* @param time
* @return
*/ public static String convertServerZoneTime(TimeZone serZone, TimeZone curZone, String time)
{
// 用户时区(本地时区)
TimeZone timeZoneUser = curZone; // 服务器时区(服务器时区)
//此方法用于将对应本地时区的时间转成服务器的时间(用于插入数据库)
//*****************
//如果用于显示到页面则需要将从数据库中取得的时间转成用户对应的时区的时间
//这样只需要交换2个时区的参数
//***************
TimeZone timeZoneServer = serZone; SimpleDateFormat inputFormat = new SimpleDateFormat(Constants.DATATIME_FORMAT);
inputFormat.setTimeZone(timeZoneUser);
Date date = null;
try
{
date = inputFormat.parse(time);
}
catch (ParseException e)
{
}
SimpleDateFormat outputFormat = new SimpleDateFormat(Constants.DATATIME_FORMAT);
outputFormat.setTimeZone(timeZoneServer);
String convertTime = outputFormat.format(date);
return convertTime;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货