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 ...
随机推荐
- wabacus JaveEE开发框架
http://www.wabacus.org/ css学习网站:http://www.divcss5.com/rumen/r422.shtml
- tensorflow-解决3个问题
问题一:对特征归一化 Min-Max Scaling: X′=a+(X−Xmin)(b−a)/(Xmax−Xmin) # Problem 1 - Implement Min-Max scaling f ...
- python之判断和循环
计算机之所以能做很多自动化的任务,因为它可以自己做条件判断.比如,输入用户年龄,根据年龄打印不同的内容,在Python程序中,可以用if语句实现: age = : print ('your age i ...
- springboot项目logback.xml或者logback-spring.xml中读取不到application.yml或application.properties配置文件中的配置解决办法
在springboot项目中我们可能想要实现不同环境的日志项目配置不同,比如我想让不同环境的日志路径不同. 这时候我们很容易想: 1.到将日志路径配置在springboot的:application- ...
- 【异常】Phoenix异常:java.lang.ArithmeticException: Rounding necessary
1 异常sql upsert into WMBIGDATA.ODS_ES_CHARGING_STATION(id,evcosType,address,serviceTel,supportOrder,o ...
- Scala获取main函数参数,idea演示
1 代码示范 /** * @author zhangjin * @create 2019-06-09 11:15 */ object TestMarnArgs { def main(args: Arr ...
- mysql数据库:分表、多表关联、外键约束、级联操作
一.分表.外键.级联.多对一 二.多对多 三.一对一 一.分表.外键.级联.多对一 将部门数据与员工数据放到同一张表中会造成 数据重复 结构混乱 扩展维护性差 需要分表 create table de ...
- 解决Zabbix某台主机突然频繁告警"Zabbix agent on xxxxxx is unreachable for x minutes"
一.某台主机突然某一天频繁告警zabbix agent不可达 查看zabbix agent日志没有发现异常 二.查看zabbix server日志发现这台主机的日志有大量报错信息"first ...
- 【input】标签去除默认样式
input{-webkit-appearance: none; -moz-appearance: none; -o-appearance: none; appearance: none;}
- 把所有时间用来做你最应该做的事,用尽全力竭尽所能成为DL and NLP大神。
两段代码,JAVA and CPP,输出相同结果: #include "stdafx.h" #include <iostream> using namespace st ...