我正在执行一个执行java jar文件的php批处理文件。当我运行命令通常它运行良好,但是当我通过PHP执行它。它给出了上述错误。java.text.ParseException:无法解析的日期:“2013年3月20日”通过从php执行批处理的jar
任何人都可以帮忙吗?
的Java:
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
//get current date time
//tdt = new java.util.Date();
Calendar c = Calendar.getInstance();
try {
tdt= sdf.parse(startdate);
} catch (ParseException ex) {
Logger.getLogger(ReportExporter.class.getName()).log(Level.SEVERE, null, ex);
}
PHP:
$command ="cmd /c ".EXPORT_BATCH_PATH." ".$fromdate." ".$todate." &";
echo $command;
$result = system($command, $output);
OR:
$command ="cmd /c ".EXPORT_BATCH_PATH." ".$fromdate." ".$todate." &";
echo $command;
$result = exec($command, $output);
当我手动运行以上回声$指令值,它运行正常。但通过php执行给出错误。
我的PHP脚本包含这一行;
<?php header('Content-type: text/html; charset=utf-8');
setlocale(LC_ALL, 'en_US');?>
是否与文本编码的任何问题?
请看接受的答案..下面的行解决了我的问题;
java -Duser.language=en -Duser.region=US -Dfile.encoding=UTF-8 -jar c:\Progra~1\MyApplication\MyApplication.jar -exportfromto %1 %2
它打印哪个错误? – javabeats 2013-03-20 14:49:15
你确定你的php命令传递了正确的日期吗?我的意思是,没有引号或其他符号。 – jmrodrigg 2013-03-20 14:51:31
是啊我执行手动输出$命令 – 2013-03-21 05:55:33