List of usage examples for java.text ParseException getErrorOffset
public int getErrorOffset()
From source file:io.hops.hopsworks.api.jobs.JobService.java
@GET @Path("/getLogByJobId/{jobId}/{submissionTime}/{type}") @Produces(MediaType.APPLICATION_JSON)/*from www .j a v a2 s . com*/ @AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST }) public Response getLogByJobId(@PathParam("jobId") Integer jobId, @PathParam("submissionTime") String submissionTime, @PathParam("type") String type) throws GenericException, JobException { if (jobId == null || jobId <= 0) { throw new IllegalArgumentException("jobId must be a non-null positive integer number."); } if (submissionTime == null) { throw new IllegalArgumentException("submissionTime was not provided."); } Jobs job = jobFacade.find(jobId); if (job == null) { throw new JobException(RESTCodes.JobErrorCode.JOB_NOT_FOUND, Level.FINE, "JobId:" + jobId); } SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); Date date; try { date = sdf.parse(submissionTime); } catch (ParseException ex) { throw new GenericException(RESTCodes.GenericErrorCode.INCOMPLETE_REQUEST, Level.WARNING, "Cannot get log. Incorrect submission time. Error offset:" + ex.getErrorOffset(), ex.getMessage(), ex); } Execution execution = exeFacade.findByJobIdAndSubmissionTime(date, job); if (execution == null) { throw new JobException(RESTCodes.JobErrorCode.JOB_EXECUTION_NOT_FOUND, Level.FINE, "JobId " + jobId); } if (!execution.getState().isFinalState()) { throw new JobException(RESTCodes.JobErrorCode.JOB_EXECUTION_INVALID_STATE, Level.FINE, "Job still running."); } if (!execution.getJob().getProject().equals(this.project)) { throw new JobException(RESTCodes.JobErrorCode.JOB_ACCESS_ERROR, Level.FINE, "Requested execution does not belong to a job of project: " + project.getName()); } JsonObjectBuilder arrayObjectBuilder = Json.createObjectBuilder(); DistributedFileSystemOps dfso = null; try { dfso = dfs.getDfsOps(); readLog(execution, type, dfso, arrayObjectBuilder); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); } finally { if (dfso != null) { dfso.close(); } } return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(arrayObjectBuilder.build()) .build(); }
From source file:org.kalypso.wspwin.core.WspWinProfProj.java
/** * Reads the file profproj.txt//from ww w . j a v a 2 s .c o m */ public void read(final File wspwinDir) throws IOException, ParseException { final WspWinProject wspWinProject = new WspWinProject(wspwinDir); final File profprojFile = wspWinProject.getProfProjFile(); try (LineNumberReader reader = new LineNumberReader(new FileReader(profprojFile));) { final int[] counts = readStrHeader(reader); final int profilCount = counts[0]; final int relationCount = counts[1]; if (relationCount == 0) { // ignore for now; later we may do sanity checks, if there are unused profiles } final ProfileBean[] profiles = ProfileBean.readProfiles(reader, profilCount); m_profiles.addAll(Arrays.asList(profiles)); } catch (final ParseException pe) { final String msg = Messages.getString("org.kalypso.wspwin.core.WspCfg.6") //$NON-NLS-1$ + profprojFile.getAbsolutePath() + " \n" + pe.getLocalizedMessage(); //$NON-NLS-1$ final ParseException newPe = new ParseException(msg, pe.getErrorOffset()); newPe.setStackTrace(pe.getStackTrace()); throw newPe; } }
From source file:org.kuali.rice.core.impl.datetime.DateTimeServiceImpl.java
protected Date parseAgainstFormatArray(String dateString, String[] formats) throws ParseException { dateString = dateString.trim();/*from ww w .j a v a 2 s .com*/ StringBuffer exceptionMessage = new StringBuffer("Date or date/time string '").append(dateString) .append("' could not be converted using any of the accepted formats: "); for (String dateFormatString : formats) { try { return parse(dateString, dateFormatString); } catch (ParseException e) { exceptionMessage.append(dateFormatString).append(" (error offset=").append(e.getErrorOffset()) .append("),"); } } throw new ParseException(exceptionMessage.toString().substring(0, exceptionMessage.length() - 1), 0); }
From source file:org.paxle.core.impl.RuntimeSettings.java
/** * @see ManagedService#updated(Dictionary) *///from w ww .j a va 2s.c o m @SuppressWarnings("unchecked") public void updated(Dictionary properties) throws ConfigurationException { if (properties == null) return; // loading current settings List<String> currentSettings = this.readSettings(); boolean changesDetected = false; // check all pre-defined options and update them in the currentSettings-list for (final OptEntry entry : OPTIONS) { final Object value = properties.get(entry.getPid()); if (value != null) changesDetected |= entry.update(currentSettings, value); } // check all other options and update the currentSettings-list final String valOthers = (String) properties.get(CM_OTHER_ENTRY.getPid()); if (valOthers != null) { final Set<String> otherSettings = new HashSet<String>(); final String[] valSplit = valOthers.split("[\\r\\n]"); for (int i = 0; i < valSplit.length; i++) { final String valOther = valSplit[i].trim(); if (valOther.length() > 0) try { for (String opt : StringTools.quoteSplit(valOther, " \t\f")) { opt = opt.trim(); if (opt.length() > 0) changesDetected |= updateSetting(otherSettings, opt); } } catch (ParseException e) { throw new ConfigurationException(CM_OTHER_ENTRY.getPid(), e.getMessage() + " at position " + e.getErrorOffset() + " in line " + i); } } /* check the currentSettings for any parameters that do not * - match a pre-defined option * - equal an user-specified option in otherSettings * and remove it. * This results in a list which only contains options which are either known or * explicitely specified by the user */ final Iterator<String> it = currentSettings.iterator(); outer: while (it.hasNext()) { final String setting = it.next(); for (final OptEntry entry : OPTIONS) if (setting.startsWith(entry.fixOpt)) continue outer; if (otherSettings.contains(setting)) continue; it.remove(); changesDetected = true; } // finally add all otherSettings to the currentSettings-list, which is for (final String setting : otherSettings) changesDetected |= updateSetting(currentSettings, setting); } if (changesDetected) { // write changes into file this.writeSettings(currentSettings); } }
From source file:org.wso2.carbon.siddhi.tryit.ui.SiddhiTryItClient.java
/** * Create time stamp for the given date and time * * @param dateTime date and time to begin the process *//*from w w w. j a v a 2 s . com*/ private long createTimeStamp(String dateTime) throws ParseException { Date date; try { date = dateFormatter.parse(dateTime); } catch (ParseException e) { errMsg = "Error occurred while parsing date " + e.getMessage(); log.error(errMsg, e); throw new ParseException(errMsg, e.getErrorOffset()); } long timeStamp = date.getTime(); return timeStamp; }
From source file:run.ejb.entite.util.runsense.UtilRsns.java
/** * * @param str//from www . j a v a 2 s . c om * @return */ public static Date stringPourDate(String str) { Date stringToDate = null; str = str.replace("/", "").replace("", "").replace(":", ""); char[] tch = str.toCharArray(); if (tch.length > 8) str = tch[4] + "" + tch[5] + "" + tch[6] + "" + tch[7] + "" + tch[2] + "" + tch[3] + "" + tch[0] + "" + tch[1] + "" + tch[8] + "" + tch[9] + "" + tch[10] + "" + tch[11] + ""; else str = tch[4] + "" + tch[5] + "" + tch[6] + "" + tch[7] + "" + tch[2] + "" + tch[3] + "" + tch[0] + "" + tch[1]; try { stringToDate = DateTools.stringToDate(str); } catch (ParseException ex) { System.err.print("UtilDateRsns stringToDate ParseException ex.getErrorOffset()"); System.out.println(ex.getErrorOffset()); System.err.print("UtilDateRsns stringToDate ParseException ex"); System.out.println(ex.getMessage()); } return stringToDate; }
From source file:ubic.basecode.util.DateUtil.java
/** * This method generates a string representation of a date/time in the format you specify on input * //from w w w .j a va2 s. c o m * @param aMask the date pattern the string is in * @param strDate a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException */ public static final Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df = null; Date date = null; df = new SimpleDateFormat(aMask); try { date = df.parse(strDate); } catch (ParseException pe) { throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); }
From source file:ubic.gemma.util.DateUtil.java
/** * This method generates a string representation of a date/time in the format you specify on input * /*w w w . j a va2s . c o m*/ * @param aMask the date pattern the string is in * @param strDate a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException */ public static final Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df = null; Date date = null; df = new SimpleDateFormat(aMask); if (log.isDebugEnabled()) { log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'"); } try { date = df.parse(strDate); } catch (ParseException pe) { throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); }