我正在管理一个来自Alfresco Properties的日期,并且在指定的时间(2010年7月13日00:00:00 CEST 2010),我需要将其转换为Java日期......我环顾四周,发现数百万各种字符串到日期转换表单的帖子以及此页面,所以我试过这样的事情:
private static final DateFormat alfrescoDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date dataRispostaDate = alfrescoDateFormat.parse(dataRisposta);
Run Code Online (Sandbox Code Playgroud)
但它引发了一个例外.(例外是(SSollevata un'eccezione durante la gestione della data:java.text.ParseException:Unparseable date:"Tue Jul 13 00:00:00 CEST 2011").
我发布完整的代码:
try {
QName currDocTypeQName = (QName) nodeService.getType(doc);
log.error("QName:["+currDocTypeQName.toString()+"]");
if (currDocTypeQName != null) {
String codAtto = AlfrescoConstants.getCodAttoFromQName(currDocTypeQName.toString());
log.error("codAtto:["+codAtto+"]");
if (codAtto.equals(AlfrescoConstants.COD_IQT)){
List<ChildAssociationRef> risposteAssociate = nodeService.getChildAssocs(doc, AlfrescoConstants.QN_RISPOSTEASSOCIATE, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef childAssocRef : risposteAssociate) {
// Vado a prendere il nodo
NodeRef risposta = childAssocRef.getChildRef();
String …Run Code Online (Sandbox Code Playgroud) 我遇到了日期解析示例日期的问题:
SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.getDefault());
parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
Run Code Online (Sandbox Code Playgroud)
得到例外
我希望将此格式日期解析为yyyy-MM-dd我尝试:
SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
Date date = parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
Run Code Online (Sandbox Code Playgroud)
take:java.text.ParseException:Unparseable date:"Wed Oct 16 00:00:00 CEST 2013"
好的,我改变并工作:
SimpleDateFormat parserSDF = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);
Date date = parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
Run Code Online (Sandbox Code Playgroud) 我正在尝试解析日期字符串,OffsetDateTime如下所示.
但我得到以下异常,
线程"main"中的异常java.time.format.DateTimeParseException:无法在索引0处解析文本'Mon Jun 18 00:00:00 IST 2012'
public class ParseExample {
public static void main(String... args) throws ParseException {
String dateStr = "Mon Jun 18 00:00:00 IST 2012";
System.out.println(OffsetDateTime.parse(dateStr));
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个错误.
谢谢.