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 ...
随机推荐
- Laravel where条件拼接,数组拼接where条件
问题描述:laravel where 条件拼接 Like出错,搜索不到要搜索的内容. 问题代码: // 作物 $crop_class_id = $request->crop_class_id; ...
- shell中sed的简单使用
sed命令行格式为: sed [-nefri] ‘command’ 输入文本/文件 常用选项: -n∶取消默认的输出,使用安静(silent)模式.在一 ...
- [转] TextCNN调参技巧
原文地址: https://plushunter.github.io/2018/02/26/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86 ...
- centos 7 Apache-Tomcat-8.5.46 安装 Web 应用服务器
tomcat 官网版本地址:https://tomcat.apache.org/whichversion.html Servlet规格 JSP规范 EL规格 WebSocket规范 JASPIC规格 ...
- 【wifi移植 2】 移植wpa_supplicant
参考文章: http://bbs.eeworld.com.cn/thread-447273-1-1.html(加精作品) 1. 下载源码 下载wpa_supplicant-2.2.tar(openss ...
- ubuntu16.04下NVIDIA GTX965M显卡驱动PPA安装
禁用nouveau驱动 Ubuntu系统集成的显卡驱动程序是nouveau,我们需要先将nouveau从linux内核卸载掉才能安装NVIDIA官方驱动.将nouveau添加到黑名单blacklist ...
- 使用remix的solidity在线编译环境部署一个faucet合约
一.浏览器打开https://remix.ethereum.org 地址 点击"+"新建一个sol文件,命名为faucet.sol 然后在代码区输入solidity代码 选择相关插 ...
- java8学习之BiFunction函数式接口实例演示&Predicate函数式接口详解
BiFunction函数式接口: 在上次中已经对BiFunction接口进行了初步的认识,这里对它进一步学习,这里打算新建一个Person实体,然后新建若干个Person的实例存放在集合中,最后再根据 ...
- 性能篇——函数调用结果的 LRU 缓存
1. 应用场景: 多次调用同一函数 2. 普通写法: def say(name): print("hellow:%s"%name) now = datetime.datetime. ...
- Java-Base64Fiend工具类
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; impo ...