日期格式转换问题

xyflash 2009-05-04 10:38:09
请问如何将这个格式: 1241400315718 转换成 这种格式:2009-05-04 09:28:00

以及将:2009-05-04 09:28:00 转换成 1241400315718 字符格式


...全文
245 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinyuehan823 2009-05-05
  • 打赏
  • 举报
回复
学习~
鱼大洋要学习 2009-05-05
  • 打赏
  • 举报
回复
private static final SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.sss");//时间格式
/**
*
*将时候格式转换成毫秒数
*/
public static Long getFromDateStringToLong(String org0){
Date date = null;

try {
date = timeFormat.parse(org0);
} catch (ParseException e) {
e.printStackTrace();
}
return date.getTime();
}
/**
*将毫秒数转换成时间格式
*/
public static String getLastTime(long time){
Date date = null;
date.setTime(time);
return timeFormat.format(date);
}
xyflash 2009-05-05
  • 打赏
  • 举报
回复
我在这个毫秒数基础上加“8”或者减“8”再转换是不是就可以将他换算成北京时间了?

说明:“8”为国际时间系数...
xyflash 2009-05-05
  • 打赏
  • 举报
回复
我的时间是个“时间戳” 请问该如何转换成“北京标准时间”
BTomcat 2009-05-04
  • 打赏
  • 举报
回复
oracle中 date_to_num(列名,‘2009-05-04 09:28:00’) 可以试下
eleven027 2009-05-04
  • 打赏
  • 举报
回复
to_char("","yyyy-mm-dd")
fafuhefan 2009-05-04
  • 打赏
  • 举报
回复
哦,还有一个问题,将字符串转成日期
DateFormat df1 =
new SimpleDateFormat("dd-MMM-yy HH:mm);


Date dd = df1.parse("18-JUN-07 20:10"); //你要得到的Date日期
jinxfei 2009-05-04
  • 打赏
  • 举报
回复

public class Test
{

public static void main(String[] args) throws Exception{
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
System.out.println(format.parse("2009-05-04 09:28:00").getTime());
System.out.println(format.format(new Date(1241400315718L)));
}
}
MT502 2009-05-04
  • 打赏
  • 举报
回复
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(format.parse("2009-05-04 09:28:00").getTime());
System.out.println(format.format(new Date(1241400480000L)));
fafuhefan 2009-05-04
  • 打赏
  • 举报
回复
SimpleDateFormat format;
format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//将时间格式转成字符串格式
String fileDate = format.format(date);

guoli0813 2009-05-04
  • 打赏
  • 举报
回复
因为那个数值是得到的时间的毫秒数,是LONG类型的数值。System.currentTimeMillis() ,
Returns the current time in milliseconds
xyflash 2009-05-04
  • 打赏
  • 举报
回复
jinxfei 1241400315718加了个“L” 是怎么意思?
yier1013 2009-05-04
  • 打赏
  • 举报
回复
java.util.Date currentTime = new java.util.Date();// 得到当前系统时间
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMddhhmmss");
String ids = formatter.format(currentTime).toString();
System.out.println(ids);

81,115

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧