Example usage for java.text SimpleDateFormat applyPattern

List of usage examples for java.text SimpleDateFormat applyPattern

Introduction

In this page you can find the example usage for java.text SimpleDateFormat applyPattern.

Prototype

public void applyPattern(String pattern) 

Source Link

Document

Applies the given pattern string to this date format.

Usage

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting year short description
 * //from  w  w  w  . ja v a 2s .c o m
 * @param year
 * @return
 */
public static String getYearShortDesc(Date year) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yy");
    return sdf.format(year);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting year long description
 * /*from  w  ww  .j av  a2 s.  co m*/
 * @param year
 * @return
 */
public static String getYearLongDesc(Date year) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy");
    return sdf.format(year);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for formatting date to ddMMyyyy format
 * // w w w.  ja  va 2s .com
 * @param date
 * @return
 */
public static String formatDateToDDMMYYYY(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("ddMMyyyy");
    return sdf.format(date);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for formatting date to dd/MM/yyyy
 * //from  w  w  w . j  av  a2  s  .com
 * @param date
 * @return
 */
public static String formatDateToDDMMYYYYWithSlash(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("dd/MM/yyyy");
    return sdf.format(date);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for//from   w  w  w.j  a  va 2  s .c  o  m
 * 
 * @param date
 * @return
 */
public static String formatDateToYYYYMMDD(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyyMMdd");
    return sdf.format(date);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for formatting date to yyyyMMddHHmmss
 * //from w ww .  j  a va2 s .  co  m
 * @param date
 * @return
 */
public static String formatDateByYYYYMMDDHHmmss(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyyMMddHHmmss");
    return sdf.format(date);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for converting format dd-MM-yyyy to date
 * //from  w  w  w .j  a  v a 2s  .  com
 * @param strDate
 * @return
 * @throws ParseException
 */
public static Date convertStringToDate(String strDate) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern(DateTimeConstants.DATE_PATTERN_LONG_YEAR);
    return sdf.parse(strDate);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for converting string into date with specific pattern
 * /*  www. ja va2s.  c  o m*/
 * @param strDate
 * @param pattern
 * @return
 * @throws ParseException
 */
public static Date convertStringToDate(String strDate, String pattern) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern(pattern);
    return sdf.parse(strDate);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for converting date to string with format dd-MM-yyyy
 * /* w ww  .j  ava2  s  .  com*/
 * @param dateArg
 * @return
 */
public static String convertDateToString(Date dateArg) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern(DateTimeConstants.DATE_PATTERN_LONG_YEAR);
    return sdf.format(dateArg);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for date to time stamp with format dd-MM-yyyy
 * hh:mm:ss aaa//  w w w .jav a  2 s  . co m
 * 
 * @param dateArg
 * @return
 */
public static String convertTimestampToString(Date dateArg) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern(DateTimeConstants.TIMESTAMP_PATTERN_LONG);
    return sdf.format(dateArg);
}