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.baidu.fsg.uid.utils.DateUtils.java

/**
 * Format date into string//from  ww w  .j  a  va  2 s .  com
 *
 * @param date
 * @param pattern
 * @return
 */
public static String formatDate(Date date, String pattern) {
    return DateFormatUtils.format(date, pattern);
}

From source file:ch.puzzle.itc.mobiliar.business.template.entity.RevisionInformation.java

public String getDisplayName() {
    return DateFormatUtils.format(revisionDate, "dd.MM.yyyy HH:mm:ss") + " (" + userName + ")";
}

From source file:com.intuit.tank.ProjectEnvelope.java

public String getCreated() {
    return DateFormatUtils.format(project.getCreated(), "dd/MM/yy HH:mm");
}

From source file:com.intuit.tank.ProjectEnvelope.java

public String getModified() {
    return DateFormatUtils.format(project.getModified(), "dd/MM/yy HH:mm");
}

From source file:com.eryansky.utils.SigarUtil.java

/**
 * ??//from   www. j  av  a2 s .c o  m
 * @throws Exception
 */
public static ServerStatus getServerStatus() throws Exception {
    ServerStatus status = new ServerStatus();
    status.setServerTime(DateFormatUtils.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
    status.setServerName(System.getenv().get("COMPUTERNAME"));

    Runtime rt = Runtime.getRuntime();
    //status.setIp(InetAddress.getLocalHost().getHostAddress());
    status.setJvmTotalMem(rt.totalMemory() / (1024 * 1024));
    status.setJvmFreeMem(rt.freeMemory() / (1024 * 1024));
    status.setJvmMaxMem(rt.maxMemory() / (1024 * 1024));
    Properties props = System.getProperties();
    status.setServerOs(props.getProperty("os.name") + " " + props.getProperty("os.arch") + " "
            + props.getProperty("os.version"));
    status.setJavaHome(props.getProperty("java.home"));
    status.setJavaVersion(props.getProperty("java.version"));
    status.setJavaTmpPath(props.getProperty("java.io.tmpdir"));

    Sigar sigar = new Sigar();
    getServerCpuInfo(sigar, status);
    getServerDiskInfo(sigar, status);
    getServerMemoryInfo(sigar, status);

    return status;
}

From source file:com.sangupta.makeup.tags.custom.DateTag.java

@Override
public boolean doTag() throws IOException {
    Date date = null;//w ww .j a  v a 2 s .co m
    String format = null;

    date = getArgument(0);
    format = getArgument(1);

    if (date == null) {
        return false;
    }

    if (format == null || format.trim().isEmpty()) {
        format = "dd MMM yyyy";
    }

    String formattedDate = DateFormatUtils.format(date, format);
    writer.write(formattedDate);

    return true;
}

From source file:com.baidu.fsg.uid.utils.DateUtils.java

/**
 * Format date by 'yyyy-MM-dd' pattern//from  w  w  w  . j a  va2s  . co  m
 *
 * @param date
 * @return
 */
public static String formatByDayPattern(Date date) {
    if (date != null) {
        return DateFormatUtils.format(date, DAY_PATTERN);
    } else {
        return null;
    }
}

From source file:com.codestudio.dorm.web.support.spring.mapper.CustomObjectMapper.java

public CustomObjectMapper() {
    CustomSerializerFactory factory = new CustomSerializerFactory();
    factory.addGenericMapping(Date.class, new JsonSerializer<Date>() {

        @Override//w  ww .  j ava 2  s.  com
        public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider) {
            try {
                if (value == null) {
                    jsonGenerator.writeString("");
                    return;
                }
                jsonGenerator.writeString(DateFormatUtils.format(value, "yyyy-MM-dd HH:mm:ss"));
            } catch (JsonGenerationException e) {
                LOGGER.error("??", e);
            } catch (IOException e) {
                LOGGER.error("??", e);
            }
        }
    });
    this.setSerializerFactory(factory);
}

From source file:cn.vlabs.umt.services.requests.impl.RequestMails.java

public void sendAcceptMail(UserRequest request, UMTContext context) {
    Properties prop = new Properties();
    setProperty(prop, "username", request.getUsername());
    setProperty(prop, "truename", request.getTruename());
    setProperty(prop, "orgnization", request.getOrgnization());
    setProperty(prop, "phonenumber", request.getPhonenumber());
    setProperty(prop, "createtime", DateFormatUtils.format(request.getCreateTime(), "yyyy-MM-dd"));
    setProperty(prop, "CurrentDate", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
    setProperty(prop, "site", context.getSiteURL());
    try {//from  w  w w .j  a  v  a  2 s .com
        sender.send(context.getLocale(), request.getEmail(), EmailTemplate.TARGET_APPROVE, prop);
    } catch (MailException e) {
        log.error(e.getMessage());
        log.debug("information", e);
    }
}

From source file:cn.vlabs.umt.ui.servlet.UMTPublicKeyServiceServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    UMTCredential cred = (UMTCredential) factory.getBean("UMTCredUtil");
    PublicKeyEnvelope opublickey = new PublicKeyEnvelope();
    opublickey.setAppId(cred.getUMTId());
    Date month = DateUtils.addMonths(new Date(cred.getCreateTime()), 1);
    opublickey.setValidTime(DateFormatUtils.format(month, "yyyy-MM-dd hh:mm:ss"));
    opublickey.setPublicKey(HexUtil.toHexString(cred.getUMTKey().getRSAPublic().getEncoded()));
    response.setContentType("text/xml");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
    out.write(opublickey.toXML());//from   ww  w  .  j a v a 2s .c o m
    out.flush();
    out.close();

}