本文整理了Java中cn.hutool.core.date.DateUtil.formatDateTime()
方法的一些代码示例,展示了DateUtil.formatDateTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.formatDateTime()
方法的具体详情如下:
包路径:cn.hutool.core.date.DateUtil
类名称:DateUtil
方法名:formatDateTime
[英]格式化日期时间
格式 yyyy-MM-dd HH:mm:ss
[中]格式化日期时间
格式 yyyy MM dd HH:MM:ss
代码示例来源:origin: looly/hutool
/**
* 当前时间,格式 yyyy-MM-dd HH:mm:ss
*
* @return 当前时间的标准形式字符串
*/
public static String now() {
return formatDateTime(new DateTime());
}
代码示例来源:origin: looly/hutool
/**
* 当前时间,格式 yyyy-MM-dd HH:mm:ss
*
* @return 当前时间的标准形式字符串
*/
public static String now() {
return formatDateTime(new DateTime());
}
代码示例来源:origin: xkcoding/spring-boot-demo
/**
* 从启动时间开始,间隔 2s 执行
* 固定间隔时间
*/
@Scheduled(fixedRate = 2000)
public void job2() {
log.info("【job2】开始执行:{}", DateUtil.formatDateTime(new Date()));
}
代码示例来源:origin: xkcoding/spring-boot-demo
/**
* 从启动时间开始,延迟 5s 后间隔 4s 执行
* 固定等待时间
*/
@Scheduled(fixedDelay = 4000, initialDelay = 5000)
public void job3() {
log.info("【job3】开始执行:{}", DateUtil.formatDateTime(new Date()));
}
}
代码示例来源:origin: xkcoding/spring-boot-demo
/**
* 按照标准时间来算,每隔 10s 执行一次
*/
@Scheduled(cron = "0/10 * * * * ?")
public void job1() {
log.info("【job1】开始执行:{}", DateUtil.formatDateTime(new Date()));
}
代码示例来源:origin: cn.hutool/hutool-all
/**
* 当前时间,格式 yyyy-MM-dd HH:mm:ss
*
* @return 当前时间的标准形式字符串
*/
public static String now() {
return formatDateTime(new DateTime());
}
代码示例来源:origin: xkcoding/spring-boot-demo
public String getStartTime() {
return DateUtil.formatDateTime(new Date(ManagementFactory.getRuntimeMXBean()
.getStartTime()));
}
代码示例来源:origin: xkcoding/spring-boot-demo
/**
* 按照标准时间来算,每隔 2s 执行一次
*/
@Scheduled(cron = "0/2 * * * * ?")
public void websocket() throws Exception {
log.info("【推送消息】开始执行:{}", DateUtil.formatDateTime(new Date()));
// 查询服务器状态
Server server = new Server();
server.copyTo();
ServerVO serverVO = ServerUtil.wrapServerVO(server);
Dict dict = ServerUtil.wrapServerDict(serverVO);
wsTemplate.convertAndSend(WebSocketConsts.PUSH_SERVER, JSONUtil.toJsonStr(dict));
log.info("【推送消息】执行结束:{}", DateUtil.formatDateTime(new Date()));
}
}
代码示例来源:origin: weechang/moreco
/**
* 属性转换
*
* @param depts 部门
*/
static void convert2String(List<Dept> depts) {
if (CollectionUtil.isNotEmpty(depts)) {
for (Dept dept : depts) {
dept.addDataMap("createdDate", DateUtil.formatDateTime(dept.getCreatedDate()));
}
}
}
代码示例来源:origin: weechang/moreco
/**
* 属性转换
*
* @param roles 角色
*/
static void convert2String(List<Role> roles) {
if (CollectionUtil.isNotEmpty(roles)) {
for (Role role : roles) {
role.addDataMap("createdDate", DateUtil.formatDateTime(role.getCreatedDate()));
}
}
}
代码示例来源:origin: weechang/moreco
/**
* 属性转换
*
* @param users 用户
*/
static void convert2String(List<User> users) {
if (CollectionUtil.isNotEmpty(users)) {
for (User user : users) {
user.addDataMap("createdDate", DateUtil.formatDateTime(user.getCreatedDate()));
user.addDataMap("status", UserStatusEnum.getNameByKey(user.getStatus()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!