字符串到日期格式 [英] string to date format

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

问题描述


如何检查文件的日期是否是今天的日期?
即FileA20120216.csv
如您所见,该efile中的日期为"20120216",我想将其与今天的日期进行比较,以查看它们是否相同.
请问这是怎么做的?
谢谢

Hi,
How do I check if the file''s date is today''s date?
i.e. FileA20120216.csv
As you can see the date in th efile is "20120216" and i would like to compare this to todays date to see if they are the same or not.
How is this done please?
Thanks

推荐答案

使用indexOf()或包含对象String的方法.
例子
use indexOf() or Contains method of object String.
Example
if (filename.IndexOf("20120216") > 0)




or

if (filename.Contains("20120216"))


u可以使用子字符串和拆分功能将ur文件名i:e"FileA20120216.csv"拆分为"20120216" ,
再次拆分u可以得到日期格式dd-mm-yyyy,从中可以将其与当前日期进行比较.

根据您使用的平台使用split/substring..
因为每个平台的语法都不同..
u can use substring and split function to split ur file name i:e "FileA20120216.csv" into "20120216",
again splitting u can get in the date format dd-mm-yyyy from where u can compare to the current date.

use the split/substring according to the platform u are using..
because in each platform the syntax differs so..


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

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