This is a small posts which helps in generating custom dates in java.
It would be helpful in data generation in Selenium.
It would be helpful in data generation in Selenium.
package com.core; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class DateClass { private static String currentDate; private static String futureDate; public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm"); Calendar cal = new GregorianCalendar(); currentDate = sdf.format(cal.getTime()); // Current date System.out.println(cal.getTime()); // Formatted current date System.out.println("Formatted Date is: " +currentDate); cal.add(Calendar.DATE, 1); futureDate = sdf.format(cal.getTime()); // Formatted future Date System.out.println("Future Date is: " +futureDate); } }
Comments
Post a Comment
No spam only genuine comments :)