![](/img/trans.png)
[英]Search of an array is not returning expected result - it keeps coming out false
[英]Date coming out, not in the manner expected
使用Java servlet构建一段HTML,并使用JsonPrimitive交付它,以显示在对话框中(为歉意而道歉),如下所示;
ja = new JsonPrimitive(
"<a href='#' onclick='return showDueDateUpdateDialogue(" + invoice.invoice_no + ", new String("+ sdfdate.format(invoice.invoice_due) +"));'>
<img border='0' class='tableImage' src='/Support/Images/Icons/application_edit.png' alt='Update due date' title='Update due date'/></a>");
这对于所有其他值都适用,但是因为我将日期格式设置为以下格式;
SimpleDateFormat sdfdate = new SimpleDateFormat("dd/MM/yyyy");
从函数showDueDateUpdateDialogue(in_no, date)
得到的日期字符串在控制台中读出为:
54003,0.0001983143282102132
我猜这是因为浏览器正在等式读取22/01/2019。 但是我真的只需要字符串值22/01/2019。
我如何获得该值,而不是22/01/2019的总和?
我尝试了使用new String()
和不使用new String()
,但除此之外,不知道如何解决。
任何想法都将大有帮助,谢谢。
您是否尝试过将日期括在“”中?
ja = new JsonPrimitive(
"<a href='#' onclick='return showDueDateUpdateDialogue(" + invoice.invoice_no + ", \""+ sdfdate.format(invoice.invoice_due) +"\");'>
<img border='0' class='tableImage' src='/Support/Images/Icons/application_edit.png' alt='Update due date' title='Update due date'/></a>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.