/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
@Override public void serialize(LocalDate localDate, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeString(localDate.toString(ISODateTimeFormat.date())); } }
@Override protected void parse(String value) throws Throwable { if (value == null || value.equalsIgnoreCase("today") || value.isEmpty()) { value = new LocalDate().toString(); // eeew } String[] fields = value.split("-"); year = Integer.parseInt(fields[0]); month = Integer.parseInt(fields[1]); day = Integer.parseInt(fields[2]); checkRangeInclusive(year, 2000, 2100); checkRangeInclusive(month, 1, 12); checkRangeInclusive(day, 1, daysInMonth[month - 1]); }
private void insertData(final LocalDate date1, DateTime date2, DateTime date3) throws SQLException { final PreparedStatement stmt = connection.prepareStatement("insert into full_of_dates (date1, datetime1, timestamp1) VALUES (?, ?, ?)"); try { // See https://github.com/killbill/killbill-commons/blob/master/jdbi/src/main/java/org/killbill/commons/jdbi/argument/LocalDateArgumentFactory.java if (date1 != null) { stmt.setString(1, date1.toString()); } // See https://github.com/killbill/killbill-commons/blob/master/jdbi/src/main/java/org/killbill/commons/jdbi/argument/DateTimeArgumentFactory.java if (date2 != null) { stmt.setTimestamp(2, new Timestamp(date2.toDate().getTime())); } // We do not use stmt.setTimestamp(3, new Timestamp(new DateTime().toDate().getTime())); stmt.execute(); } finally { if (stmt != null) { stmt.close(); } } }
@Test(groups = "fast", description = "Verify Mockito setup in GuicyKillbillTestSuite") public void testSpy() { clock.setDay(new LocalDate("2012-08-01")); Assert.assertEquals(clock.getUTCToday().toString(), "2012-08-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-08-01"); clock.addMonths(1); Assert.assertEquals(clock.getUTCToday().toString(), "2012-09-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-09-01"); clock.addDays(30); Assert.assertEquals(clock.getUTCToday().toString(), "2012-10-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-10-01"); } }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
Assert.assertThat(withJoda.getS(), is(withJsr310.getS())); Assert.assertThat(withJoda.getD().toString(), is(withJsr310.getD().toString())); Assert.assertThat(withJoda.getT().toString(), is(withJsr310.getT().toString())); Assert.assertThat(withJoda.getTs().toString(), is(withJsr310.getTs().toString()));
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
/** * swap trade constructor for exact swap dates * * @param baseCCY * @param plCCY * @param nearTenor */ public Currency(String baseCCY, String plCCY, LocalDate nearTenor, LocalDate farTenor){ this(baseCCY, plCCY, nearTenor.toString(fixDateFormat), farTenor==null ? null : farTenor.toString(fixDateFormat)); }
@Override public String marshal(LocalDate v) { if (v == null) { return null; } else { return v.toString(); } } }
/** {@inheritDoc} */ public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(value.toString()); } }
@Override public String getFormattedInvoiceDate() { final LocalDate invoiceDate = invoice.getInvoiceDate(); if (invoiceDate == null) { return ""; } else { return Strings.nullToEmpty(invoiceDate.toString(dateFormatter)); } }
/** * getDateOfLastMonth * * @return a {@link java.lang.String} object. */ public String getDateOfLastMonth(){ LocalDate dt = new LocalDate(); return dt.minusMonths(1).toString("yyyy-MM-dd"); }
@Override public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { pos.setBeginIndex(0); pos.setEndIndex(0); toAppendTo.append(((LocalDate) obj).toString(dateTimeFormatter)); return toAppendTo; }
@ManagedAttribute public String getDate() { return date().toString(); } }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append(phaseName).append(", "); sb.append(startDate.toString()).append(", "); sb.append(endDate.toString()).append(", "); sb.append(amount.toString()).append(", "); sb.append("subscriptionId = ").append(subscriptionId == null ? null : subscriptionId.toString()).append(", "); sb.append("bundleId = ").append(bundleId == null ? null : bundleId.toString()).append(", "); return sb.toString(); } }
@Test public void testToChar() throws Exception { String expectedResults[] = {(new LocalDate(2008, 2, 23)).toString("yyyy-MMM-dd"), (new LocalTime(12, 20, 30)).toString("HH mm ss"), (new LocalDateTime(2008, 2, 23, 12, 0, 0)).toString("yyyy MMM dd HH:mm:ss")}; testCommon(expectedResults, "/functions/date/to_char.json", "/test_simple_date.json"); }