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

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

Introduction

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

Prototype

public static String format(final Calendar calendar, final String pattern) 

Source Link

Document

Formats a calendar into a specific pattern.

Usage

From source file:com.mmone.gpdati.config.GpDatiProperties.java

public static void main(String[] args) {
    String s = "C:/svnprjects/mauro_netbprj/abs-ota-soapui-listener/test/FILE_DISPO__%s.txt";
    String td = DateFormatUtils.format(new Date(), "yyyyMMdd");
    System.out.println(String.format(s, td));
}

From source file:com.oz.digital.sign.window.MainView.java

/**
 * @param args the command line arguments
 *///from  ww  w . j  a  va2 s  . c o  m
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("GTK+".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | javax.swing.UnsupportedLookAndFeelException ex) {
        LOG.log(Level.SEVERE, null, ex);
    }
    //</editor-fold>

    MainView mainView = new MainView();
    mainView.setVisible(true);

    while (true) {
        final String entry = mainView.getTxtfEntry().getText();

        if (StringUtils.isNotBlank(entry)) {
            LOG.log(Level.INFO, "== Agregando la entrada : {0}", entry);

            String entryFormatted = String.format("%s -> %s\n",
                    DateFormatUtils.format(new Date(), "dd/MM/yyyy hh:mm:ss"), entry);
            mainView.getTxtAreaEntryHistory().append(entryFormatted);
        }

        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
            LOG.log(Level.SEVERE, ex.getMessage());
        }
    }
}

From source file:com.veight.common.utils.DateUtils.java

/**
 * ?
 *
 * @return 
 */
public static String format(Date date) {
    return DateFormatUtils.format(date, DEFAULT_DATE_FORMAT);
}

From source file:com.oa.product.action.MyDateUtils.java

/**
 * ? ?yyyy-MM-dd/*  w  w w  .j  a  v  a2s  .  com*/
 */
public static String getDate() {
    return DateFormatUtils.format(new Date(), "yyyy-MM-dd");
}

From source file:com.lcw.one.common.utils.DateUtils.java

/**
 * ? ?yyyy-MM-dd pattern?"yyyy-MM-dd" "HH:mm:ss" "E"
 *//*from  w  w w  .j a  v a2  s. c o m*/
public static String getDate(String pattern) {
    return DateFormatUtils.format(new Date(), pattern);
}

From source file:com.googlecode.commons.swing.util.DateUtils2.java

public static String getShortWeekday(Date d) {
    return DateFormatUtils.format(d, "EEE");
}

From source file:com.lcw.one.common.utils.DateUtils.java

/**
 *  ?yyyy-MM-dd pattern?"yyyy-MM-dd" "HH:mm:ss" "E"
 *///ww  w .j a  va  2 s.  c o  m
public static String formatDate(Date date, Object... pattern) {
    String formatDate = null;
    if (pattern != null && pattern.length > 0) {
        formatDate = DateFormatUtils.format(date, pattern[0].toString());
    } else {
        formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
    }
    return formatDate;
}

From source file:cn.mypandora.util.MyDateUtils.java

/**
 * ?.//from  ww w .  j  a  va2 s.c  o  m
 *
 * @return
 */
public static String getMonthFirstDay() {
    Calendar cal = Calendar.getInstance();
    // ,?.
    // Calendar f = (Calendar) cal.clone();
    // f.clear();
    // f.set(Calendar.YEAR, cal.get(Calendar.YEAR));
    // f.set(Calendar.MONTH, cal.get(Calendar.MONTH));
    // f.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DATE));
    // return DateFormatUtils.format(f, DATE_FORMAT);

    // .
    cal.set(Calendar.DATE, 1);
    return DateFormatUtils.format(cal, DATE_FORMAT);

}

From source file:my.extensions.app.DateTimeFormatter.java

private String format(String message) {
    String msg = "";

    try {/*from  w ww . j a  va 2s.  c o  m*/
        long ms = Long.parseLong(message, 10);
        msg = DateFormatUtils.format(ms, "yyyy-MM-dd HH:mm:ss");
    } catch (Exception e) {
        msg = e.getMessage();
    }

    return msg;
}

From source file:com.whatlookingfor.common.utils.DateUtils.java

/**
 *  ?yyyy-MM-dd)/*from  w w  w  . jav  a  2s.c o  m*/
 *
 * @param date    
 * @param pattern ?
 * @return ?
 */
public static String format(Date date, Object... pattern) {
    if (date == null) {
        return null;
    }
    String formatDate = null;
    if (pattern != null && pattern.length > 0) {
        formatDate = DateFormatUtils.format(date, pattern[0].toString());
    } else {
        formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
    }
    return formatDate;
}