Java Code Examples for org.joda.time.LocalDate#parse()
The following examples show how to use
org.joda.time.LocalDate#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDataGenerator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
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())); }
Example 2
Source File: list-get-example-4.7.x.java From api-snippets with MIT License | 6 votes |
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()); } }
Example 3
Source File: WeeklyExpiryDayValidator.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example 4
Source File: EncoderDecoderTest.java From flink with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: EncoderDecoderTest.java From flink with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: OrganisationNameNumberViewModel_Test.java From estatio with Apache License 2.0 | 5 votes |
@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]"); }
Example 7
Source File: GetRuntimeFormDefinitionCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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); } } }
Example 8
Source File: GetFormModelWithVariablesCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
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); } } }
Example 9
Source File: StatsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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); }
Example 10
Source File: FinancialYearAprilExpiryDayValidator.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example 11
Source File: LocalDateParameter.java From nomulus with Apache License 2.0 | 4 votes |
@Override public LocalDate convert(String value) { return LocalDate.parse(value, ISODateTimeFormat.date()); }
Example 12
Source File: SettingAbstract.java From estatio with Apache License 2.0 | 4 votes |
protected LocalDate parseValueAsLocalDate() { return LocalDate.parse(getValueRaw(), DATE_FORMATTER); }
Example 13
Source File: LondonTimes.java From prayer-times-android with Apache License 2.0 | 4 votes |
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; }
Example 14
Source File: ExpiryDayValidator.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected LocalDate getMaxDateCanEdit() { LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(DATE_FORMAT)); return periodDate.plusDays(expiryDays - 1); }
Example 15
Source File: DueDateAmountMap.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public LocalDate read(final JsonReader jsonReader) throws IOException { return LocalDate.parse(jsonReader.nextString(), localDatePattern); }
Example 16
Source File: ParseLocalDate.java From super-csv with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected LocalDate parse(final String string, final DateTimeFormatter formatter) { return LocalDate.parse(string, formatter); }
Example 17
Source File: Fixtures.java From dremio-oss with Apache License 2.0 | 4 votes |
public static LocalDate date(String str){ return LocalDate.parse(str); }
Example 18
Source File: DateDatum.java From incubator-tajo with Apache License 2.0 | 4 votes |
public DateDatum(String dateStr) { super(TajoDataTypes.Type.DATE); this.date = LocalDate.parse(dateStr, DEFAULT_FORMATTER); }
Example 19
Source File: FastnetImportService.java From estatio with Apache License 2.0 | 4 votes |
LocalDate stringToDate(final String dateString) { return dateString != null ? LocalDate.parse(dateString) : null; }
Example 20
Source File: DilbertPreferences.java From Simple-Dilbert with Apache License 2.0 | 2 votes |
/** * 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); }