public class CurrencyDateTime extends Object
Modifier and Type | Field and Description |
---|---|
static org.openqa.selenium.WebDriver |
driver
The driver.
|
Constructor and Description |
---|
CurrencyDateTime(org.openqa.selenium.WebDriver driver)
Instantiates a new currency and dates.
|
Modifier and Type | Method and Description |
---|---|
static Date |
addHoursToCurrentDate(int hoursToAdd)
Add hours to current date and time.
|
static String |
getCurrentDate(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder)
Returns Current Date from local system in custom format and order.
|
static String |
getCurrentDateFromNetwork(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder)
Returns Current Date from global internet server in custom format and order.
|
static Date |
getCurrentDateFromNetwork2()
Gets the current date from global internet server.
|
static Date |
getCurrentDateTimeFromNetwork()
Gets the current date and time from global internet server.
|
static String |
getCurrentDateTimeStamp()
Returns Current Date and Time from local system in format(yyyyMMdd_HHmmss)
|
static String |
getDateFromPastDays(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder,
int days)
Returns date of Past(specify difference in Days) from today in custom format and order.
|
static String |
getDateFromPastYears(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder,
int years)
Returns date from Past(specify difference in Years) from today in custom format and order.
|
static String |
getDateOfFutureDays(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder,
int days)
Returns date of Future(specify difference in Days) from today in custom format and order.
|
static String |
getDateOfFutureYears(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder,
int years)
Returns date of Future(specify difference in Years) from today in custom format and order.
|
static String |
getNextWeekSameDay(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder)
Returns nextWeekSameDay in custom format and order.
|
static String |
getTomorrowsDate(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder)
Returns tomorrow's Date in custom format and order.
|
static String |
getYesterdaysDate(String dateFormat,
String monthFormat,
String yearFormat,
String divider,
String dateMonthYearOrder)
Returns yesterday's Date in custom format and order.
|
static boolean |
isDateValid(int year,
int month,
int day)
Checks if the date passed is valid or not.
|
static boolean |
isDateValid(String date)
Checks if the date passed is valid or not.
|
static long |
subtractDateFromDateReturnDays(String date1,
String date2,
String dateMonthYearOrder)
Subtract date from date.
|
public CurrencyDateTime(org.openqa.selenium.WebDriver driver)
driver
- the driverpublic static boolean isDateValid(String date) throws Exception
date.
- Format should be "dd-MM-yyyy". Ex: 28-02-2016Exception
public static boolean isDateValid(int year, int month, int day) throws Exception
year.
- Ex: 2016month.
- Ex: 02day.
- Ex: 28Exception
public static Date getCurrentDateTimeFromNetwork() throws Exception
Exception
- the exceptionpublic static String getCurrentDateFromNetwork(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"Exception
public static Date getCurrentDateFromNetwork2() throws Exception
Exception
- the exceptionpublic static String getCurrentDate(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"Exception
public static String getCurrentDateTimeStamp() throws Exception
Exception
- the exceptionpublic static String getTomorrowsDate(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"Exception
public static String getYesterdaysDate(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"Exception
public static String getNextWeekSameDay(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"Exception
public static String getDateFromPastDays(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder, int days) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"days
- the days as int. Ex: 2Exception
public static String getDateOfFutureDays(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder, int days) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"days
- the days as int. Ex: 2Exception
public static String getDateFromPastYears(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder, int years) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"years
- the years as int. Ex: 2Exception
public static String getDateOfFutureYears(String dateFormat, String monthFormat, String yearFormat, String divider, String dateMonthYearOrder, int years) throws Exception
dateFormat
- the date format. Ex: "dd"monthFormat
- the month format. Ex: "MM" or "MMM" or "MMMM"yearFormat
- the year format. Ex: "yyyy"divider
- the divider. Ex: " " or "-" or "/"dateMonthYearOrder
- the date month year order. Ex: "dmy" or "ymd" or "myd", Also by default the order is "ymd"years
- the years as int. Ex: 2Exception
public static long subtractDateFromDateReturnDays(String date1, String date2, String dateMonthYearOrder) throws Exception
date1
- the date1 in format "yyyy MM dd". Ex: 2015 10 14date2
- the date2 in format "yyyy MM dd". Ex: 2015 10 20dateMonthYearOrder
- the date month year order for input/result date. Ex: "ymd" or "mdy" or "dmy", Also by default the order is "ymd"Exception