我使用"新日期()"显示日期/时间.
它目前显示
"Thu May 31 2012 13:04:29 GMT-0500 (CDT)".
Run Code Online (Sandbox Code Playgroud)
我需要这个:
"Thu May 31 13:04:29 CDT 2012".
Run Code Online (Sandbox Code Playgroud)
我该如何格式化?
我创建了两个框架,分别包含两个链接.
单击第一帧时,我想在第二帧中显示JSP页面.
但我无法让它发挥作用.单击第一帧时,它将在新窗口中打开JSP页面.
我粘贴了一些代码.
这是我的main.jsp
<html>
<frameset cols="50%,50%">
<frame src="frame1.jsp">
<frame src="frame2.jsp">
</frameset>
</html>
Run Code Online (Sandbox Code Playgroud)
frame1.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Frame 1 with links</title>
</head>
<body>
<body bgcolor="lightBlue">
<h2>Java Tutorial</h2>
<a href="subframe1.jsp" target="frame2.jsp"> tracking system</a>
<a href="subframe2.jsp" target="frame2.jsp">data information</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
frame2.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
subframe1.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="insertData.jsp" action="post" >
DATA ID:<input type="text" name="data_id"><br>
East:<input type="text" name="east"><br>
North:<input type="text" name="north"><br> …Run Code Online (Sandbox Code Playgroud) 我正在使用一个postgresql数据库。我将值从Java类插入数据库。我已将没有时区的数据类型为time的字段声明为String。我不知道如何解析并将其发送到与数据类型匹配的数据库?我该怎么做呢?
public static void User(Form t)
{
String insertTableSQL = "INSERT INTO DBUSER"
+ "(USER_ID, USERNAME,CREATED_DATE) VALUES"
+ "(?,?,?)";
PreparedStatement ps = dbConnection.prepareStatement(insertTableSQL);
ps.setString(1, t.getUserID());
ps.setString(2, t.getuserName());
ps.setString(3, t.getTime());
ps.executeUpdate();
}
Run Code Online (Sandbox Code Playgroud)
错误:错误:CREATED_DATE的时间不带时区,但是表达式的字符类型不同提示:尝试强制转换表达式
从 ajax 成功函数中的数组列表中检索数据。我需要根据通过 ajax 传递的 ID 填充我的文本字段纬度和经度字段。一切正常,但数据未呈现到文本字段。如果执行以下代码,成功函数将不返回任何内容。我的代码有什么问题?
获取数据类
public static ArrayList<Info> getAllInfo(String data_id) {
connection = FetchData.getConnection();
ArrayList<Info> inf = new ArrayList<Info>();
try {
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from info_table where data_id='"+data_id"'");
while(rs.next()) {
Info in=new Info();
in.setData_id(rs.getString("data_id"));
in.setLat(rs.getDouble("Lat"));
in.setLongi(rs.getDouble("Longi"));
inf.add(in);
}
} catch (SQLException e) {
e.printStackTrace();
}
return inf;
}
}
Run Code Online (Sandbox Code Playgroud)
小服务程序类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String dataID=request.getParameter("data_id");
ArrayList<Info> in=new ArrayList<Info>();
in=FetchData.getAllInfo();
Gson gson = new Gson(); …Run Code Online (Sandbox Code Playgroud) 我需要解析一个字符串到目前为止.但得到一个不可解析的例外.以下是我的代码:
String str="Sat Oct 12 09:05:00 IST 2013";
SimpleDateFormat format = new SimpleDateFormat("EEE MM DD hh:mm:ss yyyy");
try {
format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)