从文本文件中读取日期并放入对象日期 [英] read a date from a text file and put in a object date

查看:56
本文介绍了从文本文件中读取日期并放入对象日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从文件中读取日期,并以这种方式将日期写入此文件: dd / MM // yy ,但是当我读取时,我得到了价值观完全不同。例如: 10/11/17 变为 2010年1月1日CET 。值是不同的。为什么?

I have to read a Date from a file and the date is written on this file in this way: dd/MM//yy but when the I read I obtain values totally different. For example: 17/11/10 became Mon Jan 04 00:00:00 CET 2010. The value is different.why?

这是我使用的代码:

SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/YY");
Date dat=sdf.parse(reader.readLine());


推荐答案

年份的占位符为 yy ,而不是 YY 。不过,不知道为什么会得到这个结果。

The placeholder for year is yy, not YY. Don't know why it gives this result, though.

这篇关于从文本文件中读取日期并放入对象日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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