获取当前时间
public static Date Time(){
return new Date();
}
当前时间转换为“yyyy-MM-dd HH:mm:ss”
public static String Time(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date time = new Date();
String endTime = sdf.format(time);
return endTime;
}
当前时间转换为long类型毫秒数
public static long Time(){
Date time = new Date();
long endTime =time.getTime();
return endTime;
}
毫秒数转换为“yyyy-MM-dd HH:mm:ss”
public static String Time(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date time = new Date();
long begin = time.getTime();
String beginTime = sdf.format(new Date(begin))
return beginTime ;
}
毫秒数转换成时间
public static Date Time(){
Date time = new Date();
long begin = time.getTime();
return new Date(begin) ;
}
“yyyy-MM-dd HH:mm:ss”转换为时间
public static Date Time(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String beginTime = sdf.format(new Date(begin));
return sdf.parse(beginTime) ;
}