当前位置: 首页>>代码示例>>Java>>正文


Java ParseException类代码示例

本文整理汇总了Java中java.text.ParseException的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParseException类属于java.text包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import java.text.ParseException; //导入依赖的package包/类
public String next(String regexp) throws ParseException {
    trim();
    Pattern p = Pattern.compile(regexp);
    Matcher m = p.matcher(s);
    if(m.lookingAt()) {
        String r = m.group();
        s = s.substring(r.length());
        trim();
        return r;
    } else
        throw error();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:StringCutter.java

示例2: ParseUTCDate

import java.text.ParseException; //导入依赖的package包/类
Date ParseUTCDate(String s) throws ParseException {
    if (m_pISODate == null) {
        m_pISODate = Pattern.compile("(\\d+)-(\\d+)-(\\d+)T? ?(\\d+):(\\d+):(\\d+\\.?\\d*)Z?", Pattern.CASE_INSENSITIVE);
    }
    Matcher m = m_pISODate.matcher(s);

    if (m.matches()) {
        int year = Integer.parseInt(m.group(1));
        int month = Integer.parseInt(m.group(2));
        int day = Integer.parseInt(m.group(3));
        int hour = Integer.parseInt(m.group(4));
        int minute = Integer.parseInt(m.group(5));
        double second = Double.parseDouble(m.group(6));

        GregorianCalendar gc = UTCDate.UTCCalendar();
        gc.set(year, month - 1, day, hour, minute, (int) second);
        return gc.getTime();
    }
    return new Date();
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:21,代码来源:Telemetry.java

示例3: testOrderOfMainACIComponentsDoesNotMatterButMissingsMatter

import java.text.ParseException; //导入依赖的package包/类
@Test
public void testOrderOfMainACIComponentsDoesNotMatterButMissingsMatter() throws Exception
{
    String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
        + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
        + "minimum  1, maximum   2 } } }  , "
        + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
        + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }, "
        + " identificationTag \"id2\"   , precedence 14 }   ";

    try
    {
        parser.parse( spec );
        fail( "testOrderOfMainACIComponentsDoesNotMatterButMissingsMatter() should not have run this line." );
    }
    catch ( ParseException e )
    {
        assertNotNull( e );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:ACIItemParserTest.java

示例4: createPartitionedRegion

import java.text.ParseException; //导入依赖的package包/类
private Region createPartitionedRegion(String regionName) throws ParseException {
  Cache cache = CacheUtils.getCache();
  PartitionAttributesFactory prAttFactory = new PartitionAttributesFactory();
  AttributesFactory attributesFactory = new AttributesFactory();
  attributesFactory.setPartitionAttributes(prAttFactory.create());
  RegionAttributes regionAttributes = attributesFactory.create();
  return cache.createRegion(regionName, regionAttributes);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:NumericQueryJUnitTest.java

示例5: testUnderThresholdFilterTest_GLUCOSE_125_00_CGM_CGM_AVAILABLE_CGM_TH

import java.text.ParseException; //导入依赖的package包/类
@Test
public void testUnderThresholdFilterTest_GLUCOSE_125_00_CGM_CGM_AVAILABLE_CGM_TH() throws ParseException {

    UnderThresholdFilter instance = new UnderThresholdFilter(VaultEntryType.GLUCOSE_CGM, 125.00, FilterType.CGM_AVAILABLE, FilterType.CGM_TH);
    FilterResult result = instance.filter(data);

    List<VaultEntry> filteredData = new ArrayList<>();
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-09:59"), 118));
    //
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-10:29"), 110));
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-10:43"), 105));
    //
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-10:59"), 100));
    //
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-11:14"), 120));
    filteredData.add(new VaultEntry(VaultEntryType.GLUCOSE_CGM, TestFunctions.creatNewDateToCheckFor("2016.04.18-11:29"), 103));

    List<Pair<Date, Date>> timeSeries = new ArrayList<>();
    timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2016.04.18-09:59"), TestFunctions.creatNewDateToCheckFor("2016.04.18-09:59")));
    timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2016.04.18-10:29"), TestFunctions.creatNewDateToCheckFor("2016.04.18-10:43")));
    timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2016.04.18-10:59"), TestFunctions.creatNewDateToCheckFor("2016.04.18-10:59")));
    timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2016.04.18-11:14"), TestFunctions.creatNewDateToCheckFor("2016.04.18-11:29")));
    FilterResult checkForThisResult = new FilterResult(filteredData, timeSeries);

    assertEquals(result.filteredData, checkForThisResult.filteredData);
    assertEquals(result.timeSeries, checkForThisResult.timeSeries);
    //assertEquals(result, checkForThisResult);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:29,代码来源:UnderThresholdFilterTest.java

示例6: initialize

import java.text.ParseException; //导入依赖的package包/类
public void initialize(File workingDirectory, String[] arguments)
{
	if(arguments.length != 1 && arguments.length != 2 ) {
		throw new RuntimeException(usageString);
	}
	String inputFileName = arguments[0];
	this.outputFileName = inputFileName;
	if (arguments.length > 1) {
		this.outputFileName = arguments[1];
	}

	this.workingDirectory = workingDirectory;
	configTree = new ConfigTree(workingDirectory, inputFileName);
	String startDateString = configTree.getAsString(CONFIG_TREE_ELEMENT_STARTDATE, "");
	String startTimeString = configTree.getAsString(CONFIG_TREE_ELEMENT_STARTTIME, "");
	String endDateString = configTree.getAsString(CONFIG_TREE_ELEMENT_ENDDATE, "");
	String endTimeString = configTree.getAsString(CONFIG_TREE_ELEMENT_ENDTIME, "");

	String startString = startDateString + " " + startTimeString;
	String endString = endDateString + " " + endTimeString;
	double mjdStartTime;
	double mjdEndTime;
	try {
		mjdStartTime = TimeUtils.date2Mjd(startString);
		mjdEndTime = TimeUtils.date2Mjd(endString);
	} catch (ParseException e) {
		throw new RuntimeException("Could not parse start/end date time in file " + new File(workingDirectory, inputFileName));
	}
	exchangeItems = new HashMap<>();
	exchangeItems.put(PROPERTY_STARTTIME, new Flow1DTimeInfoExchangeItem(Flow1DTimeInfoExchangeItem.PropertyId.StartTime, mjdStartTime));
	exchangeItems.put(PROPERTY_STOPTIME, new Flow1DTimeInfoExchangeItem(Flow1DTimeInfoExchangeItem.PropertyId.StopTime, mjdEndTime));
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:33,代码来源:RtcToolsRuntimeConfigFile.java

示例7: main

import java.text.ParseException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, ParseException {
  if (args.length < 4) {
    StringBuilder sb = new StringBuilder();
    sb.append("current parameters: ");
    for (String one : args) {
      sb.append(one).append(",");
    }
    usage();
    return;
  }
  new PerfDataGenerator(args[0], Integer.valueOf(args[1]), Integer.valueOf(args[2]),
      Integer.valueOf(args[3])).work();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:PerfDataGenerator.java

示例8: testOffsetTime

import java.text.ParseException; //导入依赖的package包/类
@Test
public void testOffsetTime() throws ParseException {
	DateTimeApiParameterMapper mapper = new DateTimeApiParameterMapper();
	assertThat(mapper.toJdbc(OffsetTime.from(createDateTime("2000/01/01 10:10:10.010")), null, null),
			instanceOf(java.sql.Time.class));
	assertThat(mapper.toJdbc(OffsetTime.from(createDateTime("2000/01/01 10:10:10.010")), null, null),
			is(createTime("10:10:10.010")));
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:9,代码来源:DateTimeApiParameterMapperTest.java

示例9: extendsStarted

import java.text.ParseException; //导入依赖的package包/类
private void extendsStarted(Attributes attributes) throws ParseException {
    String parentOrganisation = attributes.getValue("organisation");
    String parentModule = attributes.getValue("module");
    String parentRevision = attributes.getValue("revision");
    String location = elvis(attributes.getValue("location"), "../ivy.xml");

    String extendType = elvis(attributes.getValue("extendType"), "all").toLowerCase();
    List<String> extendTypes = Arrays.asList(extendType.split(","));

    ModuleDescriptor parent;
    try {
        LOGGER.debug("Trying to parse included ivy file :{}", location);
        parent = parseOtherIvyFileOnFileSystem(location);
        if (parent != null) {
            //verify that the parsed descriptor is the correct parent module.
            ModuleId expected = IvyUtil.createModuleId(parentOrganisation, parentModule);
            ModuleId pid = parent.getModuleRevisionId().getModuleId();
            if (!expected.equals(pid)) {
                LOGGER.warn("Ignoring parent Ivy file {}; expected {} but found {}", location, expected, pid);
                parent = null;
            }
        }

        // if the included ivy file is not found on file system, tries to resolve using
        // repositories
        if (parent == null) {
            LOGGER.debug("Trying to parse included ivy file by asking repository for module :{}#{};{}",
                parentOrganisation, parentModule, parentRevision);
            parent = parseOtherIvyFile(parentOrganisation, parentModule, parentRevision);
        }
    } catch(Exception e) {
        throw (ParseException) new ParseException("Unable to parse included ivy file for " + parentOrganisation + "#" + parentModule + ";" + parentRevision, 0).initCause(e);
    }

    if (parent == null) {
        throw new ParseException("Unable to parse included ivy file for " + parentOrganisation + "#" + parentModule + ";" + parentRevision, 0);
    }

    mergeWithOtherModuleDescriptor(extendTypes, parent);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:41,代码来源:IvyXmlModuleDescriptorParser.java

示例10: getValue

import java.text.ParseException; //导入依赖的package包/类
public Object getValue(User user, Map context) {
	if (type.equals(STRING)) {
		return value;
	} else if (type.equals(INTEGER)) {
		return new Integer(value);
	} else if (type.equals(FLOAT)) {
		return new Float(value);
	} else if (type.equals(BOOLEAN)) {
		return new Boolean(value);
	} else if (type.equals(DATETIME)) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		try {
			return format.parse(value);
		} catch (ParseException e) {
			log.error( "", e );
			throw new RalasafeException(e);
		}
	} else {
		String msg="Not supported value type '" + type + "'.";
		log.error( msg );
		throw new RalasafeException(msg);
	}
}
 
开发者ID:yswang0927,项目名称:ralasafe,代码行数:24,代码来源:SimpleValue.java

示例11: toDate2

import java.text.ParseException; //导入依赖的package包/类
/**
 * 将字符串转位年月日
 * 
 * @param sdate
 * @return
 */
public static Date toDate2(String sdate) {
	try {
		return dateFormater2.get().parse(sdate);
	} catch (ParseException e) {
		return null;
	}
}
 
开发者ID:PlutoArchitecture,项目名称:Pluto-Android,代码行数:14,代码来源:StringUtils.java

示例12: str2date

import java.text.ParseException; //导入依赖的package包/类
public static Date str2date(String str, String format) {
    Date date = null;
    try {
        if (str != null) {
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            date = sdf.parse(str);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:13,代码来源:DateUtils.java

示例13: testSingle

import java.text.ParseException; //导入依赖的package包/类
@Test
public void testSingle() throws ParseException {
    LinkFormat lf = new LinkFormat("/power");
    lf.setObservable(Boolean.TRUE);
    lf.setResourceType("rt-test", "rt-test2");
    lf.setInterfaceDescription("if-test");
    lf.setMaximumSize(123);
    lf.setResourceInstance("ri-test");
    lf.setExport(Boolean.TRUE);
    lf.setMedia("text/plain");
    lf.setTitle("my title");
    lf.setType("example type");
    lf.setAnchor("/test/anch");
    lf.setContentType((short) 12);
    lf.setOAutobservable(true);

    LinkFormat lf2 = LinkFormatBuilder.parse(lf.toString());

    assertEquals(lf, lf2);
    assertEquals(lf.getUri(), lf2.getUri());
    assertEquals(lf.getContentType(), lf2.getContentType());
    assertEquals(lf.getResourceTypeArray(), lf2.getResourceTypeArray());
    assertEquals(lf.getInterfaceDescriptionArray(), lf2.getInterfaceDescriptionArray());
    assertEquals(lf.isObservable(), lf2.isObservable());
    assertEquals(lf.getMaxSize(), lf2.getMaxSize());
    assertEquals(lf.getResourceInstance(), lf2.getResourceInstance());
    assertEquals(lf.getExport(), lf2.getExport());
    assertEquals(lf.getMedia(), lf2.getMedia());
    assertEquals(lf.getTitle(), lf2.getTitle());
    assertEquals(lf.getType(), lf2.getType());
    assertEquals(lf.getAnchor(), lf2.getAnchor());
    assertEquals(lf.getParam("href"), lf.getUri());
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:34,代码来源:LinkFormatTest.java

示例14: DERUTCTime

import java.text.ParseException; //导入依赖的package包/类
/**
 * The correct format for this is YYMMDDHHMMSSZ (it used to be that seconds were
 * never encoded. When you're creating one of these objects from scratch, that's
 * what you want to use, otherwise we'll try to deal with whatever gets read from
 * the input stream... (this is why the input format is different from the getTime()
 * method output).
 * <p>
 *
 * @param time the time string.
 */
public DERUTCTime(
    String  time)
{
    this.time = time;
    try
    {
        this.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:24,代码来源:DERUTCTime.java

示例15: formatDate

import java.text.ParseException; //导入依赖的package包/类
public static Date formatDate(String csDate, String csFormat, boolean strict)
{
	Date date = null;

	if (csDate != null && csFormat != null && csFormat.length() > 0) 
	{
		try 
		{
			SimpleDateFormat formatter = new SimpleDateFormat(csFormat);
			formatter.setLenient(false);
			date = formatter.parse(csDate);
			if (strict) 
			{
				if (csFormat.length() != csDate.length()) 
				{
					date = null;
				}
			}
		} 
		catch (ParseException e) 
		{
		}
	}
	return date;
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:26,代码来源:DateUtil.java


注:本文中的java.text.ParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。