我正在尝试转换日期..........
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
cv::Mat matResultImage = [self findSquaresInImage:image];
dispatch_async( dispatch_get_main_queue(), ^{
self.imageView.image = [JKUtilityClass UIImageFromCVMat:matResultImage];
});
});
但它给出了例外:
String date = null ;
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.000'+'0530");
date = Utils.getDateBasedOnCurrentDate(mPosition);
Date attendancedate = dateFormat.parse(date);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
date = format.format(attendancedate);
Log.e("ddddddddddddddddddd", date);
}catch (ParseException e){
e.printStackTrace();
}
答案 0 :(得分:0)
使用
更改此行 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.000'+'0530");
此
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
答案 1 :(得分:0)
试试这个答案:
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
// String inputPattern = "EEE MMM d HH:mm:ss zzz yyyy";
String outputPattern = "dd-MM-yyyy";
//SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
//Date date = null;
String str = null;
try {
String time = sdfDate.format(now);
//date = inputFormat.parse(time);
str = outputFormat.format(now);
Log.i("mini1", "Converted Date Today:" + time);
Log.i("mini", "Converted Date Today:" + str);
// Toast.makeText(getApplicationContext(), str, 5000).show();
} catch (ParseException e) {
e.printStackTrace();
}