在jmeter的beanshell中用java获取系统当前时间的简单实例

时间:2022-06-17 10:03:15

代码如下:


import java.util.*; 
int y,m,d,h,mi,s;     
Calendar cal=Calendar.getInstance();     
y=cal.get(Calendar.YEAR);     
m=cal.get(Calendar.MONTH);     
d=cal.get(Calendar.DATE);     
h=cal.get(Calendar.HOUR_OF_DAY);     
mi=cal.get(Calendar.MINUTE);     
s=cal.get(Calendar.SECOND);  
System.out.println("The current time is:"+y+"/"+m+"/"+d+"/"+h+"/"+mi+"/"+s+"/");  
vars.put("Date",m+"/"+d+"/"+y);