This code can also be used in selenium to get Test Case Start Time and Test Case End Time. We can develop function as developed in below mentioned code i.e. tNow(). This function can be used before the start of each test and at the end of each test (e.g. start of for loop and end of for loop).
Find below the code for Current Time:
Find below the code for Current Time:
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class timeFunction { public static void main(String[] args) { System.out.println(tNow()); } //Generate current start time and end time public static String tNow(){ //DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); Calendar cal = Calendar.getInstance(); String currTime=dateFormat.format(cal.getTime()); return currTime; } }
No comments:
Post a Comment