public static String parseDateTime(String date,String formatFrom,String formatTo){
DateTimeFormatter formatter = DateTimeFormat.forPattern(formatFrom);
DateTime dt = formatter.parseDateTime(date);
Date dn=dt.toDate();
SimpleDateFormat dateFormat = new SimpleDateFormat(formatTo);
dateFormat.format(dn);
return dateFormat.format(dn);
} public static void main(String[] args) {
System.out.println(parseDateTime("20080402","yyyyMMdd","yyyy-MM-dd HH:mm:ss"));
}

输出

2008-04-02 00:00:00

注意,使用了joda插件

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

joda日期格式转换的更多相关文章

  1. 日期格式转换 java 2016-09-03T00:00:00.000+08:00

    /**  * 日期格式转换yyyy-MM-dd'T'HH:mm:ss.SSSXXX  (yyyy-MM-dd'T'HH:mm:ss.SSSZ) TO  yyyy-MM-dd HH:mm:ss  * @ ...

  2. Oracle日期格式转换,tochar(),todate()

    Oracle日期格式转换 本文主要介绍Oracle中的日期转换. 1. 日期转化为字符串 (以2016年10月20日为例) select to_char(sysdate,'yyyy-mm-dd hh2 ...

  3. SpringMVC与MyBatis整合之日期格式转换

    在上一篇博客<SpringMVC与MyBatis整合(一)——查询人员列表>中遗留了日期格式转换的问题,在这篇记录解决过程. 对于controller形参中pojo对象,如果属性中有日期类 ...

  4. Python 日期格式转换

    经常需要爬取网站上的时间信息,不同的网站又有不同的日期显示方式.而我需要将日期格式转化为一种特定的格式,所以为了简便和学习,记录下各种不同的日期格式转换. 日期格式化符号: %y :两位数的年份表示( ...

  5. 在SQL Server中 获取日期、日期格式转换

    --常用日期转换参数: PRINT CONVERT(varchar, getdate(), 120 ) 2016-07-20 16:09:01 PRINT replace(replace(replac ...

  6. ABAP - 日期格式转换 &amp; ABAP经常使用日期处理函数

    ABAP - 日期格式转换 如今提供下面一些日期格式转换的函数: Below are several FMs which can be used to convert date format. 1. ...

  7. freemark声明变量,boolean,date,date日期格式转换成String类型的(五)

    <br/>assign用来定义变量<#assign name="刘德华"><br/> 获取assign定义变量的值:${name} <br ...

  8. ssm日期格式转换

    ssm日期格式转换 1      需求 前端传入字符串类型日期转化成java中的Date类型,存入数据库中;将数据库中的日期类型通过jstl标签在前端页面转换成字符串类型. 2      步骤 2.1 ...

  9. Nullable<System.DateTime>日期格式转换 (转载)

    一.问题 1.html页面中时间显示出错,数据库中时间是正确的. 原因:没有把DateTime转成String类型. 2.  在C#中,发现不能直接使用ToString("yyyy-MM-d ...

随机推荐

  1. Zookeeper 简单操作

    1.  连接到zookeeper服务 [java2000_wl@localhost zookeeper-3]$ bin/zkCli.sh -server 127.0.0.1:2181 也可以连接远端的 ...

  2. Hive中行列转换

    1.演示多列转为单行 数据文件及内容: student.txt xiaoming|english|92.0 xiaoming|chinese|98.0 xiaoming|math|89.5 huahu ...

  3. NS3网络仿真(12): ICMPv4协议

    快乐虾 http://blog.csdn.net/lights_joy/ 欢迎转载,但请保留作者信息 ICMP的全称是 Internet ControlMessage Protocol . 其目的就是 ...

  4. Android碎纸机效果

    1.总体思想 活用padding和margin 2.实现过程 public class PopupShredderView extends FrameLayout{ public PopupShred ...

  5. 设置清除html5页面缓存

    设置清除html5页面缓存 html5端设置 meta 标签: <meta http-equiv="Pragma" content="no-cache" ...

  6. MySQL迁移到SQLServer

    手头有个Java老项目,数据库是基于MySQL的,我们要把它迁移到SQLServer2008. 采用微软的SSMA For MySQL:迁移助手Microsoft SQL Server Migrati ...

  7. 2016/04/18 ①注册 注册处理 ② 审核 审核处理 ③登录 登录处理 ④需要jquery-1.11.2.min.js DBDA.php

    ① 注册   zhuceye.php <!DOCTYPE html> <html lang="en"> <head> <meta char ...

  8. Vue框架之组件系统

    1,Vue组件系统之全局组件 1.1Vue全局组件的在实例化调用Vue的模板中导入组件的名称 <!DOCTYPE html> <html lang="zh-cn" ...

  9. USING REFLECTION

    In this section, you take a closer look at the System.Type class, which enables you to access inform ...

  10. mysql workbench快捷键

    注释/取消注释, ctrl+/   暂时不知道怎么设置(原配置是 ctrl+divide)格式化sql语句(美化sql语句), ctrl+b