本文整理汇总了Java中java.time.format.DateTimeParseException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java DateTimeParseException.getMessage方法的具体用法?Java DateTimeParseException.getMessage怎么用?Java DateTimeParseException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.format.DateTimeParseException
的用法示例。
在下文中一共展示了DateTimeParseException.getMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseUtcTimeyyyyMMddhhmmss
import java.time.format.DateTimeParseException; //导入方法依赖的package包/类
public static Date parseUtcTimeyyyyMMddhhmmss(String utcTime) {
String coreUtcTime = utcTime;
if (StringUtil.isNotBlank(utcTime)) {
char ch = utcTime.charAt(utcTime.length() - 1);
if (ch == 'z' || ch == 'Z') {
coreUtcTime = utcTime.substring(0, utcTime.length() - 1);
}
}
if (coreUtcTime == null || coreUtcTime.length() != 14) {
throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'");
}
try {
LocalDateTime localDate = LocalDateTime.parse(coreUtcTime, SDF1);
Instant instant = localDate.atZone(ZONE_UTC).toInstant();
return Date.from(instant);
} catch (DateTimeParseException ex) {
throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': "
+ ex.getMessage());
}
}
示例2: parseUtcTimeyyyyMMdd
import java.time.format.DateTimeParseException; //导入方法依赖的package包/类
public static Date parseUtcTimeyyyyMMdd(String utcTime) {
String coreUtcTime = utcTime;
if (StringUtil.isNotBlank(utcTime)) {
char ch = utcTime.charAt(utcTime.length() - 1);
if (ch == 'z' || ch == 'Z') {
coreUtcTime = utcTime.substring(0, utcTime.length() - 1);
}
}
if (coreUtcTime == null || coreUtcTime.length() != 8) {
throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'");
}
try {
LocalDateTime localDate = LocalDateTime.parse(coreUtcTime + "000000", SDF1);
Instant instant = localDate.atZone(ZONE_UTC).toInstant();
return Date.from(instant);
} catch (DateTimeParseException ex) {
throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': "
+ ex.getMessage());
}
}
示例3: maakFileTime
import java.time.format.DateTimeParseException; //导入方法依赖的package包/类
private FileTime maakFileTime(final String time) throws MojoExecutionException {
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
try {
return FileTime.from(LocalDateTime.from(formatter.parse(time)).toInstant(ZoneOffset.UTC));
} catch (DateTimeParseException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
示例4: load
import java.time.format.DateTimeParseException; //导入方法依赖的package包/类
/**
* Sent the sparql query to dbpedia service and load rdf data parsed into {@link IDataProducer} object.
* The dbpedia service return a rdf response with nodes corresponding to the fields requested
*
* @param dataProducer which allows to push {@link Event} in queue
* @throws NullPointerException if dataProducer is null
* @see DBpediaProducerConnector#source
* @see DBpediaProducerConnector#service
* @see DBpediaProducerConnector#latitudeMax
* @see DBpediaProducerConnector#latitudeMin
* @see DBpediaProducerConnector#longitudeMax
* @see DBpediaProducerConnector#longitudeMin
* @see DBpediaProducerConnector#resource
* @see DBpediaProducerConnector#sleepTime
* @see DBpediaProducerConnector#limit
*/
@Override
public void load(IDataProducer dataProducer) {
Objects.requireNonNull(dataProducer);
while (!Thread.interrupted()) {
QueryExecution qexec = null;
long start = System.currentTimeMillis();
try {
String query = "prefix db-owl: <http://dbpedia.org/ontology/>\n" +
"prefix url-resource: <http://fr.dbpedia.org/resource/>\n" +
"PREFIX dbo: <http://dbpedia.org/ontology/> \n" +
"prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
"prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
"prefix prop-fr: <http://fr.dbpedia.org/property/>\n" +
"prefix dc: <http://purl.org/dc/elements/1.1/>\n" +
"select * where {\n" +
" ?evenements rdf:type db-owl:Event .\n" +
" ?evenements db-owl:wikiPageWikiLink url-resource:" + resource + " .\n" +
" OPTIONAL {\n" +
" ?evenements prop-fr:latitude ?latitude .\n" +
" ?evenements prop-fr:longitude ?longitude .\n" +
" ?evenements rdfs:comment ?description .\n" +
" ?evenements dbo:startDate ?startDate .\n " +
" ?evenements dbo:endDate ?endDate .\n" +
" ?evenements rdfs:label ?label .\n" +
" FILTER (\n" +
" ?latitude >= " + latitudeMin + " && \n" +
" ?latitude < " + latitudeMax + " && \n" +
" ?longitude >= " + longitudeMin + " && \n" +
" ?longitude < " + longitudeMax + " \n" +
" )\n" +
" }\n" +
"} LIMIT " + limit;
Query request = QueryFactory.create(query);
qexec = QueryExecutionFactory.sparqlService(service, request);
ResultSet resultSet = qexec.execSelect();
while (resultSet.hasNext()) {
QuerySolution qs = resultSet.nextSolution();
RDFNode latitudeNode = qs.get("latitude");
RDFNode longitudeNode = qs.get("longitude");
RDFNode descriptionNode = qs.get("description");
RDFNode startDateNode = qs.get("startDate");
RDFNode endDateNode = qs.get("endDate");
Event event = getEventFromRDFNodes(latitudeNode, longitudeNode, startDateNode, endDateNode, descriptionNode, source);
pushIfValidEvent(dataProducer, event, start);
}
Thread.sleep(this.sleepTime);
} catch (IllegalStateException err) {
LOGGER.error("The current query can't be executed: {}", err);
Thread.currentThread().interrupt();
return;
} catch (DateTimeParseException dtp) {
LOGGER.error("bad date format given: ", dtp);
throw new IllegalStateException(dtp.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
if (qexec != null) {
qexec.close();
}
}
}
}