格式从14 aug到YYYYMMDD [英] format date from 14 aug to YYYYMMDD

查看:100
本文介绍了格式从14 aug到YYYYMMDD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将日期14 Aug 2011更改为格式20110814 ..我如何在java中执行?

Change the date 14 aug 2011 to the format 20110814 .. how can i do that in java ?

这里是一个字符串... String date =

Here 14aug is a string ... String date="14aug";

推荐答案

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
df.format(date)

参考: java.text.SimpleDateFormat

更新:精英绅士的问题很重要。如果您从 String 开始,那么您应该首先解析它以从上面的示例获取 date 对象:

Update: the question by The Elite Gentleman is important. If you start with a String, then you should first parse it to obtain the date object from the above example:

Date date = new SimpleDateFormat("dd MMM yyyy").parse(dateString);

这篇关于格式从14 aug到YYYYMMDD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆