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


Java LocalDate.parse方法代码示例

本文整理汇总了Java中java.time.LocalDate.parse方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.parse方法的具体用法?Java LocalDate.parse怎么用?Java LocalDate.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDate的用法示例。


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

示例1: between

import java.time.LocalDate; //导入方法依赖的package包/类
@GET
@Path("/between/{start}/{end}")
@Produces(MediaType.APPLICATION_JSON)
public List<PictureThumb> between(@PathParam("start") String start, @PathParam("end") String end){
    System.out.println("Between " + start + " and " + end);
    final LocalDate startDate = LocalDate.parse(start, DateTimeFormatter.ISO_DATE);
    final LocalDate endDate = LocalDate.parse(end, DateTimeFormatter.ISO_DATE);
    final List<PictureThumb> retval = new ArrayList<>();
    try {
        Files.list(IMAGES_ROOT)
                //.filter(p -> p.getFileName().toString().startsWith(start))
                .filter(p -> p.getFileName().toString().endsWith(".jpeg"))
                .sorted()
                .map(ImagesEndpoint::convert)
                .forEach(retval::add);
    } catch (IOException ex) {
        Logger.getLogger(ImagesEndpoint.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    
    return retval;
}
 
开发者ID:erikcostlow,项目名称:PiCameraProject,代码行数:23,代码来源:ImagesEndpoint.java

示例2: test_parse_resolve_localizedWom

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField womField = week.weekOfMonth();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(MONTH_OF_YEAR).appendLiteral(':')
                .appendValue(womField).appendLiteral(':')
                .appendValue(DAY_OF_WEEK).toFormatter().withResolverStyle(SMART);
        String str = date.getYear() + ":" + date.getMonthValue() + ":" +
                date.get(womField) + ":" + date.get(DAY_OF_WEEK);
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, date, " ::" + str + "::" + i);

        date = date.plusDays(1);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TCKWeekFields.java

示例3: test_parse_resolve_localizedWoyDow_lenient

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWoyDow_lenient(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField dowField = week.dayOfWeek();
    TemporalField woyField = week.weekOfYear();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(woyField).appendLiteral(':')
                .appendValue(dowField).toFormatter().withResolverStyle(LENIENT);
        int woy = date.get(woyField);
        int dow = date.get(dowField);
        for (int j = woy - 60; j < woy + 60; j++) {
            String str = date.getYear() + ":" + j + ":" + dow;
            LocalDate parsed = LocalDate.parse(str, f);
            assertEquals(parsed, date.plusWeeks(j - woy), " ::" + str + ": :" + i + "::" + j);
        }

        date = date.plusDays(1);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TCKWeekFields.java

示例4: test_parse_resolve_localizedWoWBY_lenient

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWoWBY_lenient(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 31);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField wowbyField = week.weekOfWeekBasedYear();
    TemporalField yowbyField = week.weekBasedYear();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(yowbyField).appendLiteral(':')
                .appendValue(wowbyField).appendLiteral(':')
                .appendValue(DAY_OF_WEEK).toFormatter().withResolverStyle(LENIENT);
        int wowby = date.get(wowbyField);
        int dow = date.get(DAY_OF_WEEK);
        for (int j = wowby - 60; j < wowby + 60; j++) {
            String str = date.get(yowbyField) + ":" + j + ":" + dow;
            LocalDate parsed = LocalDate.parse(str, f);
            assertEquals(parsed, date.plusWeeks(j - wowby), " ::" + str + ": :" + i + "::" + j);
        }

        date = date.plusDays(1);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TCKWeekFields.java

示例5: test_parse_resolve_localizedWoWBY_strict

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWoWBY_strict(DayOfWeek firstDayOfWeek, int minDays) {
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField wowbyField = week.weekOfWeekBasedYear();
    TemporalField yowbyField = week.weekBasedYear();
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(yowbyField).appendLiteral(':')
            .appendValue(wowbyField).appendLiteral(':')
            .appendValue(DAY_OF_WEEK).toFormatter().withResolverStyle(STRICT);
    String str = "2012:0:1";
    try {
        LocalDate date = LocalDate.parse(str, f);
        assertEquals(date.get(yowbyField), 2012);
        assertEquals(date.get(wowbyField), 0);
        assertEquals(date.get(DAY_OF_WEEK), 1);
    } catch (DateTimeException ex) {
        // expected
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKWeekFields.java

示例6: getCurrentSpotRosterView

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
@Transactional
public SpotRosterView getCurrentSpotRosterView(Integer tenantId) {
    List<TimeSlot> timeSlotList = entityManager.createNamedQuery("TimeSlot.findAll", TimeSlot.class)
            .setParameter("tenantId", tenantId)
            .getResultList();
    LocalDate startDate;
    LocalDate endDate;
    if (timeSlotList.isEmpty()) {
        startDate = LocalDate.parse("1900-01-01");
        endDate = LocalDate.parse("2900-01-01");
    } else {
        startDate = timeSlotList.get(0).getStartDateTime().toLocalDate();
        endDate = timeSlotList.get(timeSlotList.size() - 1).getStartDateTime().toLocalDate();
    }
    return getSpotRosterView(tenantId, startDate, endDate, entityManager.createNamedQuery("Spot.findAll",
            Spot.class)
            .setParameter("tenantId", tenantId)
            .getResultList());
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:21,代码来源:RosterRestServiceImpl.java

示例7: createEmployee

import java.time.LocalDate; //导入方法依赖的package包/类
private static Employee createEmployee() throws Exception {
	// Get the employee info from the command prompt
	System.out.println("Please, input the employee info:");
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	System.out.print("Name: ");
	String name = reader.readLine();
	System.out.print("Date of Birth (yyyy-MM-dd): ");
	String dob = reader.readLine();
	LocalDate dobDate = LocalDate.parse(dob, formatter);
	System.out.print("Address: ");
	String address = reader.readLine();
	System.out.print("Salary: ");
	double salary = Double.parseDouble(reader.readLine());
	System.out.print("Do you want to add a photo? (Y/N): ");
	String yesNo = reader.readLine();
	byte[] bytesBlob = null;
	// Insert new record: begin
	if (yesNo.equalsIgnoreCase("Y")) {
		// With photo
		System.out.print("Type the file name as it appears in folder /photos, including extension: ");
		String fileName = reader.readLine();
		File photo = new File("./photos/" + fileName);
		InputStream streamBlob = new FileInputStream(photo);
		bytesBlob = new byte[streamBlob.available()];
	}
	// Create the object
	Employee emp = new Employee(name, dobDate, address, salary, bytesBlob, null);
	
	// Begin transaction
	em.getTransaction().begin();
	// Store the object
	em.persist(emp);
	// End transaction
	em.getTransaction().commit();
	
	// Return the Employee
	return emp;
}
 
开发者ID:rgarciacarmona,项目名称:JPA-Demo,代码行数:39,代码来源:JPAUpdateRelated.java

示例8: convertFactValue

import java.time.LocalDate; //导入方法依赖的package包/类
private FactValue convertFactValue(Tokens tokens) 
{

	FactValue fv = null;
	switch(tokens.tokensString)
	{
		case "De":
			fv = FactValue.parse(tokens.tokensList.get(0));
			break;
		
		case "No":
			fv = FactValue.parse(tokens.tokensList.get(0));
			break;
			
		case "Da":
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy");
      		LocalDate factValueInDate = LocalDate.parse(tokens.tokensList.get(0), formatter);				
      		fv = FactValue.parse(factValueInDate);
      		break;
      		
		case "Url":
			fv = FactValue.parseURL(tokens.tokensList.get(0));
			break;
			
		case "Id":
			fv = FactValue.parseUUID(tokens.tokensList.get(0));
			break;
			
		case "Ha":
			fv = FactValue.parseHash(tokens.tokensList.get(0));
	}
	return fv;
}
 
开发者ID:DeanLee77,项目名称:Nadia,代码行数:34,代码来源:IterateLine_1.java

示例9: test_parse_weeks_LENIENT

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider="week")
public void test_parse_weeks_LENIENT(LocalDate date, DayOfWeek dow, int week, int wby) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f);
    assertEquals(parsed, date);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TCKIsoFields.java

示例10: parse

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public Map<String, String> parse(String content) throws ParserException {
	Map<String, String> extra = new HashMap<>();

	try {
		LocalDate date = LocalDate.parse(content, marc);
		extra.put("normalized", date.format(iso));
	} catch(DateTimeParseException e) {
		throw new ParserException(String.format(
			"Invalid content: '%s'. %s", content, e.getMessage()));
	}
	return extra;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:14,代码来源:YYYYMMDDDateParser.java

示例11: weekly

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LinkedHashMap<LocalDate, Stock> weekly(String symbol, HashMap<String, String> options) throws UnsupportedEncodingException, InvalidApiKeyException, InvalidFunctionOptionException, MalFormattedFunctionException, MissingApiKeyException, UltraHighFrequencyRequestException {
    String function = "TIME_SERIES_WEEKLY";
    String queryString = ALPHA_VANTAGE_API_URL + "function=" + function + "&symbol=" + symbol + "&apikey=" + apiKey + "&";
    String encodedUrl = options.keySet().stream().map(key -> {
        try {
            return key + "=" + UriUtils.encode(options.get(key), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }).collect(joining("&", queryString, ""));

    LinkedHashMap<LocalDate, Stock> result = new LinkedHashMap<>();
    JsonNode jsonNode = restTemplate.getForObject(encodedUrl, JsonNode.class);
    Iterator<Map.Entry<String, JsonNode>> it = jsonNode.fields();
    while (it.hasNext()) {
        Map.Entry<String, JsonNode> mapEntry = it.next();
        ExceptionUtil.handleException(mapEntry, function);
        if (mapEntry.getKey().equals("Weekly Time Series")) {
            JsonNode node = mapEntry.getValue();
            Iterator<Map.Entry<String, JsonNode>> timeSeriesIter = node.fields();
            while (timeSeriesIter.hasNext()) {
                Map.Entry<String, JsonNode> timeSeriesMap = timeSeriesIter.next();
                LocalDate localDate = LocalDate.parse(timeSeriesMap.getKey(), DateTimeFormatter.ISO_LOCAL_DATE);
                String open = String.valueOf(timeSeriesMap.getValue().get("1. open")).replaceAll("\"", "");
                String high = String.valueOf(timeSeriesMap.getValue().get("2. high")).replaceAll("\"", "");
                String low = String.valueOf(timeSeriesMap.getValue().get("3. low")).replaceAll("\"", "");
                String close = String.valueOf(timeSeriesMap.getValue().get("4. close")).replaceAll("\"", "");
                String volume = String.valueOf(timeSeriesMap.getValue().get("5. volume")).replaceAll("\"", "");
                result.put(localDate, Stock.newStpckInstance(symbol, open, high, low, close, volume));
            }

        }
    }
    return result;
}
 
开发者ID:cautiontowind,项目名称:alpha-vantage,代码行数:38,代码来源:StockTemplate.java

示例12: test_parse_parseLenientQuarter_LENIENT

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider = "parseLenientQuarter")
public void test_parse_parseLenientQuarter_LENIENT(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral(':')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(str, f);
    assertEquals(parsed, expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例13: factory_parse_formatter_nullFormatter

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    LocalDate.parse("ANY", null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKLocalDate.java

示例14: unmarshal

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate unmarshal(String date)
{
    return LocalDate.parse(date.substring(0, 10));
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:6,代码来源:LocalDateXmlAdapter.java

示例15: deleteMessage

import java.time.LocalDate; //导入方法依赖的package包/类
private static RealtimeMessage deleteMessage(Kv78Packet packet, Map<String, String> r) {
    return new DeleteMessage(r.get("DataOwnerCode"), LocalDate.parse(r.get("MessageCodeDate")),
            Integer.valueOf(r.get("MessageCodeNumber")), r.get("TimingPointCode")); //r.get("TimingPointDataOwnerCode")
}
 
开发者ID:CROW-NDOV,项目名称:displaydirect,代码行数:5,代码来源:RealtimeMessageMapper.java


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