Friday, 4 August 2017

Code Example - Get Current Date

package com.practiceCode;

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

import org.testng.annotations.Test;

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 4-08-2017
 *
 */
public class GetCurrentDate {

@Test
public void testGetCurrentDate() {

try {
// "dd-MMM-YYYY hh:mm a"
DateFormat dateFormat2 = new SimpleDateFormat("dd-MMM-YYYY hh:mm a");
Date date2 = new Date();

String today = dateFormat2.format(date2);
System.out.println("Current date is :  " + today);

} catch (Exception e) {
e.printStackTrace();
}
}
}

No comments:

Post a Comment

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...