【参考文章】: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 相互转换的更多相关文章

  1. LocalDateTime、LocalDate、Long、Date、String 相互转换

    DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); ...

  2. [mysql]Date和String相互转换(DATE_FORMAT&STR_TO_DATE)

    1.Date  ——>  String 使用的函数:DATE_FORMAT(date,format)     date:需要转换的日期       format:格式化的样式 format样式整 ...

  3. date和string转换用joda包

    import org.joda.time.DateTime;import org.joda.time.format.DateTimeFormat;import org.joda.time.format ...

  4. 异常-----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 ...

  5. 【python】time,datetime,string相互转换

    来源:http://essen.iteye.com/blog/1452098 #把datetime转成字符串 def datetime_toString(dt): return dt.strftime ...

  6. Python的time,datetime,string相互转换

    #把datetime转成字符串 def datetime_toString(dt): return dt.strftime("%Y-%m-%d-%H") #把字符串转成dateti ...

  7. Date与String之间相互转换

    项目中经常用到,Date类型与String类型的转换,所以写个工具类 直接贴代码: package com.elite.isun.utils; import java.text.ParseExcept ...

  8. python datetime date time详解

    之前一直被datetime,date,time弄的有点乱,可能是因为看文档每太看明白,找到了两篇文章供大家阅读都是转载的,其中有些名词这里解释一下: 世界协调时间(Universal Time Coo ...

  9. MySQL5.6中date和string的转换和比较

    Conversion & Comparison, involving strings and dates in MySQL 5.6 我们有张表,表中有一个字段dpt_date,SQL类型为da ...

随机推荐

  1. O035、Nova Suspend / Rescue 操作详解

    参考https://www.cnblogs.com/CloudMan6/p/5503501.html   Suspend / Resume   有时候需要长时间暂停 instance , 可以通过 S ...

  2. 向PHP发送HTTP-Post请求

    欢迎访问我的个人博客,获取更多有用的东西 链接一 链接二 也可以关注我的微信订阅号:CN丶Moti 1.post.html <!DOCTYPE html> <html lang=&q ...

  3. vue transtion 实现分析

    这是我用js和css3,实现的vue transition组件相同的效果核心js var btn = document.getElementById('btn'); var box = null bt ...

  4. Windows 10 安装FileZilla Server

    在windows 10本机安装了FileZilla Server 本机用FilleZilla Client连接localhost或者192.168.0.197  port 21  都可以连通,但是在同 ...

  5. 判断一个数是否为回文数(js)

    //判断是否为回文数:若n=1234321,则称n为一回文数 let readline = require("readline-sync"); let newNum = 0; co ...

  6. 通过javascript得到当前的日期和计算出该班级的平均分

    某班的成绩出来了,现在老师要把班级的成绩打印出来. 格式要求: 1.显示打印的日期. 格式为类似“XXXX年XX月XX日 星期X” 的当前的时间. 2.计算出该班级的平均分(保留整数). 同学成绩数据 ...

  7. Go语言并发机制

    Go语言中的并发 使用goroutine编程 使用 go 关键字用来创建 goroutine .将go声明放到一个需调用的函数之前,在相同地址空间调用运行这个函数,这样该函数执行时便会作为一个独立的并 ...

  8. C++虚函数和纯虚函数的用法和区别

    C++虚函数与纯虚函数用法与区别(转)   1. 虚函数和纯虚函数可以定义在同一个类(class)中,含有纯虚函数的类被称为抽象类(abstract class),而只含有虚函数的类(class)不能 ...

  9. Python单元测试框架unittest重要属性 与 用例编写思路

    前言 本文为转载,原文地址作者列举python unittest这个测试框架的主要属性和 测试用例思路 unittest单元测试框架不仅可以适用于单元测试,还可以适用WEB自动化测试用例的开发与执行, ...

  10. 从一道Hard学习滑动窗口

    滑动窗口 滑动窗口(sliding windows algorithm)这种方法,专门用于解决区间解的问题.它在运算的时候,将解集放在窗口中,结束的时候比对是否符合预期.在运算的过程中,会对窗口的左右 ...