我想知道Java中是否有任何方法可以做到这一点.否则我可能会使用Regex解决方案.
我有来自用户的输入字符串,可以是任何字符.我想检查输入字符串是否符合我所需的日期格式.
因为我输入20130925并且我所需的格式是dd/MM/yyyy所以,对于这种情况我应该是假的.
我不想转换这个日期我只想检查输入字符串是否符合所需的日期格式.
我试过以下
Date date = null;
try {
date = new SimpleDateFormat("dd/MM/yyyy").parse("20130925");
} catch (Exception ex) {
// do something for invalid dateformat
}
Run Code Online (Sandbox Code Playgroud)
但我的catch(Exception ex)块无法捕获SimpleDateFormat.Parse()生成的任何异常;
我想将一个转换ArrayList为List<string>使用LINQ.我试过ToList()但这种方法不起作用:
ArrayList resultsObjects = new ArrayList();
List<string> results = resultsObjects.ToList<string>();
Run Code Online (Sandbox Code Playgroud) 我在Windows上创建了一些shell脚本,我想在它们上运行Dos2Unix.
但正如我已经读到Dos2Unix在Linux环境中工作所以,在Windows中工作时,我可以将文件转换为UNIX格式吗?
我已经安装了CYGWIN但是我遇到了一些问题
Administrator@SGH735082N ~
$ pwd
/home/Administrator
Administrator@SGH735082N ~
$ cd C:\CVS Code
Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix BLPDB000
BLPDB000:
dos2Unix processing BLPDB000: No such file or directory
Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix -h
dos2Unix: bad argument -h: unknown option
Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix --help
dos2Unix version 0.1.3
converts the line endings of text files from
DOS style (0x0d 0x0a) to UNIX style (0x0a)
Usage: dos2Unix [OPTION...] [input file list...]
Main options (not all may …Run Code Online (Sandbox Code Playgroud) I have tired to uninstall a disabled windows service through registry It is removed from registry but it is still showing in Services.msc with
Description: Failed to read description error code 2
任何人都可以告诉我这个命令是什么意思吗?
selfDir=$(cd "$(dirname "$0")"; pwd) ?
Run Code Online (Sandbox Code Playgroud)
我知道
$0 = 运行脚本名称pwd = 当前工作目录cd = 改变目录我需要的是dirname是什么?什么?意味着最后使这条线完全可以理解。
我想在按钮点击时调用两个函数我试过这样
<asp:Button ID="Button2" runat="server" Font-Bold="False" onclick="tableShow();Unnamed1_Click" Text="Search"
Width="63px">
Run Code Online (Sandbox Code Playgroud) 我有这个代码
SimpleDateFormat ft = new SimpleDateFormat ("dd/MM/yyyy");
String sDate="2013-11-13";
String formattedDate=ft.format( ft.parse(sDate));
Run Code Online (Sandbox Code Playgroud)
但这不起作用.任何帮助