org.joda.time.LocalDate#parse ( )源码实例Demo

下面列出了org.joda.time.LocalDate#parse ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Flink-CEPplus   文件: TestDataGenerator.java
public static User generateRandomUser(Random rnd) {
	return new User(
			generateRandomString(rnd, 50),
			rnd.nextBoolean() ? null : rnd.nextInt(),
			rnd.nextBoolean() ? null : generateRandomString(rnd, 6),
			rnd.nextBoolean() ? null : rnd.nextLong(),
			rnd.nextDouble(),
			null,
			rnd.nextBoolean(),
			generateRandomStringList(rnd, 20, 30),
			generateRandomBooleanList(rnd, 20),
			rnd.nextBoolean() ? null : generateRandomStringList(rnd, 20, 20),
			generateRandomColor(rnd),
			new HashMap<>(),
			generateRandomFixed16(rnd),
			generateRandomUnion(rnd),
			generateRandomAddress(rnd),
			generateRandomBytes(rnd),
			LocalDate.parse("2014-03-01"),
			LocalTime.parse("12:12:12"),
			123456,
			DateTime.parse("2014-03-01T12:12:12.321Z"),
			123456L,
			ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()),
			new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
}
 
源代码2 项目: api-snippets   文件: list-get-example-4.7.x.java
public static void main(String[] args) {
  Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

  LocalDate lower = LocalDate.parse("2009-07-06");
  LocalDate higher = LocalDate.parse("2009-07-08");

  ResourceSet<Notification> notifications = Notification.reader()
      .setMessageDate(Range.closed(lower, higher))
      .setLog(1)
      .read();

  // Loop over notifications and print out a property for each one.
  for (Notification notification : notifications) {
    System.out.println(notification.getRequestUrl());
  }
}
 
@Override
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(getDateFormat()));
    periodDate = periodDate.withDayOfWeek(weekStarts());
    periodDate = periodDate.plusDays(6);
    return periodDate.plusDays(expiryDays - 1);
}
 
源代码4 项目: flink   文件: EncoderDecoderTest.java
@Test
public void testGeneratedObjectWithNullableFields() {
	List<CharSequence> strings = Arrays.asList(new CharSequence[] { "These", "strings", "should", "be", "recognizable", "as", "a", "meaningful", "sequence" });
	List<Boolean> bools = Arrays.asList(true, true, false, false, true, false, true, true);
	Map<CharSequence, Long> map = new HashMap<>();
	map.put("1", 1L);
	map.put("2", 2L);
	map.put("3", 3L);

	byte[] b = new byte[16];
	new Random().nextBytes(b);
	Fixed16 f = new Fixed16(b);
	Address addr = new Address(239, "6th Main", "Bangalore", "Karnataka", "560075");
	User user = new User(
		"Freudenreich",
		1337,
		"macintosh gray",
		1234567890L,
		3.1415926,
		null,
		true,
		strings,
		bools,
		null,
		Colors.GREEN,
		map,
		f,
		Boolean.TRUE,
		addr,
		ByteBuffer.wrap(b),
		LocalDate.parse("2014-03-01"),
		LocalTime.parse("12:12:12"),
		123456,
		DateTime.parse("2014-03-01T12:12:12.321Z"),
		123456L,
		ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()), // 20.00
		new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); // 20.00

	testObjectSerialization(user);
}
 
源代码5 项目: flink   文件: EncoderDecoderTest.java
@Test
public void testGeneratedObjectWithNullableFields() {
	List<CharSequence> strings = Arrays.asList(new CharSequence[] { "These", "strings", "should", "be", "recognizable", "as", "a", "meaningful", "sequence" });
	List<Boolean> bools = Arrays.asList(true, true, false, false, true, false, true, true);
	Map<CharSequence, Long> map = new HashMap<>();
	map.put("1", 1L);
	map.put("2", 2L);
	map.put("3", 3L);

	byte[] b = new byte[16];
	new Random().nextBytes(b);
	Fixed16 f = new Fixed16(b);
	Address addr = new Address(239, "6th Main", "Bangalore", "Karnataka", "560075");
	User user = new User(
		"Freudenreich",
		1337,
		"macintosh gray",
		1234567890L,
		3.1415926,
		null,
		true,
		strings,
		bools,
		null,
		Colors.GREEN,
		map,
		f,
		Boolean.TRUE,
		addr,
		ByteBuffer.wrap(b),
		LocalDate.parse("2014-03-01"),
		LocalTime.parse("12:12:12"),
		123456,
		DateTime.parse("2014-03-01T12:12:12.321Z"),
		123456L,
		ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()), // 20.00
		new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); // 20.00

	testObjectSerialization(user);
}
 
@Test
public void title_works() throws Exception {

    // given
    final String organisationName = "Some organisation name";
    final String chamberOfCommerceCode = "123456789";
    final LocalDate entryDate = LocalDate.parse("2019-01-01");
    OrganisationNameNumberViewModel vm = new OrganisationNameNumberViewModel(organisationName, chamberOfCommerceCode, entryDate);

    // then
    Assertions.assertThat(vm.title()).isEqualTo("Some organisation name 123456789 [2019-01-01]");

}
 
public void fillVariablesWithFormValues(Map<String, JsonNode> submittedFormFieldMap, List<FormField> allFields) {
  for (FormField field : allFields) {
    
    JsonNode fieldValueNode = submittedFormFieldMap.get(field.getId());

    if (fieldValueNode == null || fieldValueNode.isNull()) {
      continue;
    }

    String fieldType = field.getType();
    String fieldValue = fieldValueNode.asText();

    if (FormFieldTypes.DATE.equals(fieldType)) {
      try {
        if (StringUtils.isNotEmpty(fieldValue)) {
          LocalDate dateValue = LocalDate.parse(fieldValue);
          variables.put(field.getId(), dateValue);
        }
      } catch (Exception e) {
        logger.error("Error parsing form date value for process instance " + processInstanceId + " with value " + fieldValue, e);
      }

    } else {
      variables.put(field.getId(), fieldValue);
    }
  }
}
 
源代码8 项目: alfresco-remote-api   文件: StatsGet.java
/**
 * Parses ISO8601 formatted Date Strings.
 * @param start If start is null then defaults to 1 month
 * @param end If end is null then it defaults to now();
 */
public static Pair<LocalDate, LocalDate> getStartAndEndDates(String start, String end)
{
    if (start == null) return null;
    LocalDate startDate = LocalDate.parse(start);
    LocalDate endDate = end!=null?LocalDate.parse(end):LocalDate.now();
    return new Pair<LocalDate, LocalDate>(startDate, endDate);
}
 
@Override
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period,
            DateTimeFormat.forPattern(DATE_FORMAT));
    periodDate = periodDate.withMonthOfYear(monthOfYear());
    periodDate = periodDate.plusMonths(plusMonths());
    return periodDate.plusDays(expiryDays - 2);
}
 
public void fillVariablesWithFormInstanceValues(Map<String, JsonNode> formInstanceFieldMap, List<FormField> allFields, String formInstanceId) {
    for (FormField field : allFields) {

        JsonNode fieldValueNode = formInstanceFieldMap.get(field.getId());

        if (fieldValueNode == null || fieldValueNode.isNull()) {
            continue;
        }

        String fieldType = field.getType();
        String fieldValue = fieldValueNode.asText();

        if (FormFieldTypes.DATE.equals(fieldType)) {
            try {
                if (StringUtils.isNotEmpty(fieldValue)) {
                    LocalDate dateValue = LocalDate.parse(fieldValue);
                    variables.put(field.getId(), dateValue.toString("yyyy-M-d"));
                }
                
            } catch (Exception e) {
                LOGGER.error("Error parsing form date value for form instance {} with value {}", formInstanceId, fieldValue, e);
            }
            
        } else if (fieldValueNode.isBoolean()) {
            variables.put(field.getId(), fieldValueNode.asBoolean());
            
        } else if (fieldValueNode.isLong()) {
            variables.put(field.getId(), fieldValueNode.asLong());
            
        } else if (fieldValueNode.isDouble()) {
            variables.put(field.getId(), fieldValueNode.asDouble());

        } else {
            variables.put(field.getId(), fieldValue);
        }
    }
}
 
源代码11 项目: estatio   文件: SettingAbstract.java
protected LocalDate parseValueAsLocalDate() {
    return LocalDate.parse(getValueRaw(), DATE_FORMATTER);
}
 
源代码12 项目: estatio   文件: FastnetImportService.java
LocalDate stringToDate(final String dateString) {
    return dateString != null ? LocalDate.parse(dateString) : null;
}
 
源代码13 项目: incubator-tajo   文件: DateDatum.java
public DateDatum(String dateStr) {
  super(TajoDataTypes.Type.DATE);
  this.date = LocalDate.parse(dateStr, DEFAULT_FORMATTER);
}
 
源代码14 项目: dremio-oss   文件: Fixtures.java
public static LocalDate date(String str){
  return LocalDate.parse(str);
}
 
源代码15 项目: super-csv   文件: ParseLocalDate.java
/**
 * {@inheritDoc}
 */
@Override
protected LocalDate parse(final String string,
		final DateTimeFormatter formatter) {
	return LocalDate.parse(string, formatter);
}
 
源代码16 项目: fenixedu-academic   文件: DueDateAmountMap.java
@Override
public LocalDate read(final JsonReader jsonReader) throws IOException {
    return LocalDate.parse(jsonReader.nextString(), localDatePattern);
}
 
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(DATE_FORMAT));
    return periodDate.plusDays(expiryDays - 1);
}
 
源代码18 项目: prayer-times-android   文件: LondonTimes.java
protected boolean sync() throws ExecutionException, InterruptedException {
    try {
        final Trust trust = new Trust();
        final TrustManager[] trustmanagers = new TrustManager[]{trust};
        SSLContext sslContext;


        Ion ion = Ion.getDefault(App.get());
        sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, trustmanagers, new SecureRandom());

        ion.configure().createSSLContext("TLS");

        ion.getHttpClient().getSSLSocketMiddleware().setSSLContext(sslContext);
        ion.getHttpClient().getSSLSocketMiddleware().setTrustManagers(trustmanagers);

    } catch (NoSuchAlgorithmException | KeyManagementException e) {
        e.printStackTrace();
    }

    Result r = Ion.with(App.get())
            .load("https://www.londonprayertimes.com/api/times/?formatDate=json&key=1e6f7b94-542d-4ff7-94cc-e9c8e0bd2e64&year=" + LocalDate.now().getYear())
            .setTimeout(3000)
            .userAgent(App.getUserAgent())
            .as(Result.class)
            .get();
    int i = 0;

    DateTimeFormatter pattern = DateTimeFormat.forPattern("yyyy-MM-dd");
    for (Times t : r.times.values()) {
        t.fixTimes();

        LocalDate ld = LocalDate.parse(t.date, pattern);
        setTime(ld, Vakit.FAJR, t.fajr);
        setTime(ld, Vakit.SUN, t.sunrise);
        setTime(ld, Vakit.DHUHR, t.dhuhr);
        setTime(ld, Vakit.ASR, t.asr);
        setTime(ld, Vakit.MAGHRIB, t.magrib);
        setTime(ld, Vakit.ISHAA, t.isha);
        setAsrThani(ld, t.asr_2);
        i++;
    }

    return i > 10;
}
 
源代码19 项目: nomulus   文件: LocalDateParameter.java
@Override
public LocalDate convert(String value) {
  return LocalDate.parse(value, ISODateTimeFormat.date());
}
 
源代码20 项目: Simple-Dilbert   文件: DilbertPreferences.java
/**
 * First strip was published on 16.4.1989
 *
 * @return LocalDate date of first Dilbert comics strip
 * @see <a href="http://en.wikipedia.org/wiki/Dilbert">Wikipedia</a>
 */
public static LocalDate getFirstStripDate() {
    return LocalDate.parse("1989-04-16",
            DilbertPreferences.DATE_FORMATTER);
}