Source Code : Checking date as String formatted by a date format
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Checking date as String formatted by a date format
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Utility for checking date as String formatted by a date format.
* By default, the date format u
*
* @see java.text.DateFormat
*/
public class DateUtils {
public static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH:mm");
private static DateFormat dateFormat = DEFAULT_DATE_FORMAT;
private DateUtils() {
// Instanceless class
}
/**
* Returns the date from the given value parsed by the date format.
*/
public static Date getDate(String yyyyMMdd) throws ParseException {
synchronized (dateFormat) {
return dateFormat.parse(yyyyMMdd);
}
}
/**
* Returns the Date as String formated by the date format.
*/
public static String getStandardDate(Date date) {
synchronized (dateFormat) {
return dateFormat.format(date);
}
}
/**
* Sets the date format.
*/
public static void setDateFormat(DateFormat dateFormat) {
DateUtils.dateFormat = dateFormat;
}
}
Thank with us