java如何把时间格式转为毫秒
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class Cat {
public static void main(String[] args) throws ParseException {
String str = “201104141302”;
SimpleDateFormat sdf = new SimpleDateFormat(“yyyyMMddhhmm”);
long millionSeconds = sdf.parse(str).getTime();//毫秒
System.out.println(millionSeconds);
}
}
——————-
1302757320000
java数据转换问题:下面方法是将时间转换成秒,怎么能把这个时间在转换成原来的时间格式00:00:00.0啊?
SimpleDateFormat dateformat=new SimpleDateFormat("HH:mm:ss. E "); String a2=dateformat2.format(new Date()); 即可 想要什么格式就什么格式 很简单的 SimpleDateFormat还可以加年月日 等等 如:SimpleDateFormat dateformat2=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ");
Java 格式化时间问题
你把sdf.format(new Date())赋给jointime当然是不可以的,因为 string和date如何匹配呢,date永远是“sat apr 23 23:23:23 cst 2000”这种格式,SimpleDateFormat 只是拿出其中部分来显示,一般做法是
再建个 private String jointimeStr;
public setJointmeStr(){
SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd “);
if(this.getJointme()!=null){
jointimeStr=sdf.format(this.getJointme());
}
return jointimeStr;
}
在页面上拿jointimeStr显示;
所以
SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd “);
String a2=sdf.format(new Date());
还是要发出来的~
【Java基础】在格式化字符串中想显示毫秒和微秒的时候报错 求教怎么回事?
Date date = new Date (); System.out.format ("%tH:%tM:%tS.%tL %tN", date, date, date, date, date);
JAVA里的时间和日期格式化的语法和方法
Calendar calendar = Calendar.getInstance(); Date time = calendar.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String times = sdf.format(time);
Java:时间格式化,如何追加时分秒?
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime);
JAVA里如何时间格式化
Date t=new Date(); SimpleDateFormat s=new SimpleDateFormat("yy年MM月dd日"); System.out.println(s.format(t));
java 时间格式化
SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss"); Date dt = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss.SSS").parse("2010-04-13 12:40:37.187"); String time = sdf.format(dt);
java中怎么把时间格式如“2011 – 03 – 02 23:54:34” 转换为“110302”,时分秒省略
Date d = new Date(); String s=DateFormat.getDateInstance(DateFormat.DEFAULT).format(d); System.out.println(s); 这个是得到时间的时候格式化数据.
时间格式化java
如将时间200911120000转换为2009-11-12 00:00:00 DateFormat format = new SimpleDateFormat("yyyyMMddHHmm"); Date dDate = format.parse("200911120000"); DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String reTime = format2.format(dDate); System.out.println(reTime);