我正在使用此格式"Sun May 17 2015 09:31:49"
的客户端API之一在Calender对象中获取Date,但我希望它显示在Sun May 17 00:00:00 IST 2015
中。我尝试了下面的代码,但它以这种格式SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");
String input = "2015-05-17T09:31:49";
Date t = ft.parse(input);
System.out.println(t.toString());
function hightLight(ele)
{
ele.parentElement.parentElement.className = "highlight";
}
document.write("<table id=appTable border=1 style=margin-top:10px; margin-left:10px;>");
document.write("<tr><th>Select</th><th>Name</th><th>Location</th><th>Action</th></tr>");
for (row=1; row<5; row++)
{
document.write("<tr>");
for (col=1; col<=4; col++)
{
if(col==1)
{ document.write("<td><input type='checkbox' id='mapCheck' name='myTextEditBox' /></td>");
}
if(col==2)
document.write("<td width='140'>Name</td>");
if(col==3)
document.write("<td width='200'>Location</td>");
if(col==4)
document.write("<td><button onclick='hightLight(this)' type='button'>select</button></td>");
}
document.write("</tr>");
}
document.write("</table>");
有人请指导我如何做到这一点。
答案 0 :(得分:0)
检查这可以帮助您:
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-mmm-dd HH:mm:ss");
String input = "2015-05-17 09:31:49";
Date t = ft.parse(input);
System.out.println(t.toString());
答案 1 :(得分:0)
java.text.DateFormat outputFormat =new java.text.SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss");
java.text.DateFormat outputFormat1 =new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
System.out.println(outputFormat.format(outputFormat1.parse("2015-05-17T09:31:49")));//Sun May 17 2015 09:31:49