//获取当前时间类,并储存为特定的函数

import java.util.Date;
import java.text.SimpleDateFormat;

public class GetCorrentTime {
   public static  SimpleDateFormat  GetTime() {     
   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
 
      return df;// new Date()为获取当前系统时间
   }
}

 

//调用前面的那个类

SimpleDateFormat Time=GetCorrentTime.GetTime(); //返回一个SimpleDateFormat类的对象

Time.format( new java.util.Date()) // new date() 获取系统时间,并转化为特定格式

相关文章:

  • 2022-12-23
  • 2021-08-25
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案