Joda-DateTime Date 与 String 相互转换
【参考文章】:Joda-Time 的 DateTimeFormat 问题
public class DateFormatUtils { /** HH 必须大写 */
public static final String FORMAT_FULL_TIME_NO_ZONE = "yyyy-MM-dd HH:mm:ss"; public static Date toFormatDate(String dateTimeStr) {
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(FORMAT_FULL_TIME_NO_ZONE);
DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr);
return dateTime.toDate();
}
public static String toFormatString(Date date) {
return new DateTime(date).toString(FORMAT_FULL_TIME_NO_ZONE);
} public static String toFormatString(Date date, String pattern) {
return new DateTime(date).toString(pattern);
}
}
Joda-DateTime Date 与 String 相互转换的更多相关文章
- LocalDateTime、LocalDate、Long、Date、String 相互转换
DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); ...
- [mysql]Date和String相互转换(DATE_FORMAT&STR_TO_DATE)
1.Date ——> String 使用的函数:DATE_FORMAT(date,format) date:需要转换的日期 format:格式化的样式 format样式整 ...
- date和string转换用joda包
import org.joda.time.DateTime;import org.joda.time.format.DateTimeFormat;import org.joda.time.format ...
- 异常-----Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-
1.错误描述 五月 27, 2014 12:07:05 上午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
- 【python】time,datetime,string相互转换
来源:http://essen.iteye.com/blog/1452098 #把datetime转成字符串 def datetime_toString(dt): return dt.strftime ...
- Python的time,datetime,string相互转换
#把datetime转成字符串 def datetime_toString(dt): return dt.strftime("%Y-%m-%d-%H") #把字符串转成dateti ...
- Date与String之间相互转换
项目中经常用到,Date类型与String类型的转换,所以写个工具类 直接贴代码: package com.elite.isun.utils; import java.text.ParseExcept ...
- python datetime date time详解
之前一直被datetime,date,time弄的有点乱,可能是因为看文档每太看明白,找到了两篇文章供大家阅读都是转载的,其中有些名词这里解释一下: 世界协调时间(Universal Time Coo ...
- MySQL5.6中date和string的转换和比较
Conversion & Comparison, involving strings and dates in MySQL 5.6 我们有张表,表中有一个字段dpt_date,SQL类型为da ...
随机推荐
- MongoDB 基础增删改查
增删改查 基础操作 use show dbs show collections db[当前所在数据库] 插入文档 db.collection.insert() db.collection.insert ...
- 用最少的JS代码写出贪吃蛇游戏---迷你版
游戏进行页面展示 GAME OVER 页面展示 代码如下: <!doctype html> <html> <body> <canvas id=&q ...
- 上传图片,语音,和富文本(webuploader,dropzone, froala)
首先是上传图片,使用的百度webuploader 自己修改后可以实例化多个uploader对象: HTML: <!DOCTYPE html> <html xmlns="ht ...
- Fescar锁和隔离级别的理解
前几天夜里,我老大发我一篇文章说阿里的GTS开源了. 因为一直对分布式事务比较感兴趣,立马pull了代码,进行阅读.基本的原理,实现方案我就不一一细化了,详细见官方文档(写的很棒,点赞). 在fesc ...
- axios+post获取并下载后台返回的二进制流
axios+post获取并下载后台返回的二进制流 let url = $.getCookie('prefixUrl')+'/expenseword/exportWords'; let vm = thi ...
- Java注解【五、注解实战】
需求: 1.表:用户ID,用户名,年龄,邮箱. 2.实现方法,传入实体,打印sql. 实现: 1.表: package Annotation; @Table("user") pub ...
- python中F/f表达式优于format()表达式
F/f表达式可以解析任意类型的数据 具体实现,看下面示例: 1.解析变量 1 a = 10 3 b = 20 5 res1 = F"a+b的值:{a+b}" 7 print(res ...
- linux命令详解——top
简介 TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系 ...
- spket IDE插件更新地址
http://www.agpad.com/update spket IDE插件更新地址
- Capture 设置pin name 不可见
在器件库文件页面空白处双击,自动弹出OPTIONS对话框,再设计PIN NAME 可见属性为FLASE. 双击管脚.不管用,改不了.