Example usage for org.apache.commons.lang.time DateFormatUtils format

List of usage examples for org.apache.commons.lang.time DateFormatUtils format

Introduction

In this page you can find the example usage for org.apache.commons.lang.time DateFormatUtils format.

Prototype

public static String format(Date date, String pattern) 

Source Link

Document

Formats a date/time into a specific pattern.

Usage

From source file:com.khs.report.StandardReportHeader.java

public static String[] defaultHeader(String programName, String reportId, String headerLine1,
        String headerLine2, String headerLine3) {
    Calendar cal = Calendar.getInstance();
    String date = DateFormatUtils.format(cal, ReportingDefaultConstants.DATE_FORMAT);
    String time = DateFormatUtils.format(cal, ReportingDefaultConstants.TIME_FORMAT);

    String[] header = new String[] { "DATE:" + date + "~" + headerLine1 + "~PAGE: #",
            "TIME:" + time + "~" + headerLine2 + "~RPT : " + reportId,
            "PRGM:" + programName + "~" + headerLine3 + "~"

    };//from   ww w.j  av  a 2s . co  m
    return header;
}

From source file:com.alibaba.ims.platform.util.DateUtil.java

/**
 * ?/*from   w  w w.j  a v a2s.com*/
 *
 * @param date
 * @param pattern
 * @return
 */
public static String format(Date date, String pattern) {
    if (date == null) {
        return "";
    }
    return DateFormatUtils.format(date, pattern);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static String formatToDate(Date date) {
    return DateFormatUtils.format(date, DATE_PATTERN);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static String formatToDateTime(Date date) {
    return DateFormatUtils.format(date, DATE_TIME_PATTERN);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static String formatToTime(Date date) {
    return DateFormatUtils.format(date, TIME_PATTERN);
}

From source file:net.sourceforge.fenixedu.util.CalendarUtil.java

public static String date2string(Calendar date) {
    return DateFormatUtils.format(date.getTime(), "yyyyMMdd");
}

From source file:com.vaadin.addon.jpacontainer.demo.util.DateUtils.java

/**
 * Calculates the hash code based on the day of <code>date</code> only.
 * @param date the date whose hash code should be calculated (may be null).
 * @return the hash code.//from   ww w  . jav a2s . com
 */
public static int sameDayHashCode(Date date) {
    if (date == null) {
        return 0;
    } else {
        return DateFormatUtils.format(date, "yyyy-MM-dd").hashCode();
    }
}

From source file:com.fengduo.bee.commons.core.utils.Identities.java

public final static String getVehicleCode() {
    Random random = new Random();
    return DateFormatUtils.format(new Date(), PURE_MIDDLE_DATE_TIME_FORMAT_STR)
            + RandomUtils.nextInt(random, 10) + RandomUtils.nextInt(random, 10);
}

From source file:com.codestudio.dorm.domain.serializer.DateSerializer.java

@Override
public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider arg2)
        throws IOException, JsonProcessingException {
    jsonGenerator.writeString(DateFormatUtils.format(value, "yyyy-MM-dd HH:mm"));
}

From source file:com.fengduo.bee.commons.core.utils.Identities.java

public final static String getTimestampUUID() {
    return DateFormatUtils.format(new Date(), PURE_MIDDLE_DATE_TIME_FORMAT_STR) + RandomUtils.nextInt(10);
}