Package org.joda.time

Examples of org.joda.time.DateTime.toDateTime()


    }

    @Test
    public void testAnotherBasicConvert() throws Exception {
        DateTime date = (DateTime) new DateConverter(config("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ")).convert("2014-05-19T00:30:43.116847+00:00");
        assertEquals("2014-05-19T00:30:43.116Z", date.toDateTime(DateTimeZone.UTC).toString());
    }

    @Test(expectedExceptions = ConfigurationException.class)
    public void testWithEmptyConfig() throws Exception {
        assertEquals(null, new DateConverter(config("")).convert("foo"));
View Full Code Here


        System.out.println("Copy & set to Jan:    in.monthOfYear().setCopy(1):            " + in.monthOfYear().setCopy(1));
        System.out.println("Copy & add 14 months: in.monthOfYear().addCopy(14):           " + in.monthOfYear().addToCopy(14));
        System.out.println("Add 14 mnths in field:in.monthOfYear().addWrapFieldCopy(14):  " + in.monthOfYear().addWrapFieldToCopy(14));
        System.out.println("...");
        System.out.println("Convert to Instant:   in.toInstant():           " + in.toInstant());
        System.out.println("Convert to DateTime:  in.toDateTime():          " + in.toDateTime());
        System.out.println("Convert to MutableDT: in.toMutableDateTime():   " + in.toMutableDateTime());
        System.out.println("Convert to Date:      in.toDate():              " + in.toDate());
        System.out.println("Convert to Calendar:  in.toCalendar(Locale.UK): " + in.toCalendar(Locale.UK).toString().substring(0, 46));
        System.out.println("Convert to GregCal:   in.toGregorianCalendar(): " + in.toGregorianCalendar().toString().substring(0, 46));
        System.out.println("");
View Full Code Here

            DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime());
            if (out == null) {
                return null;
            }
           
            return out.toDateTime();
    } catch (Exception e) {
      throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value));
    }
  }
}
View Full Code Here

        }

        @Override
        public void serialize(Object value, DataOutput dataOutput) {
            DateTime dateTime = (DateTime) value;
            dateTime = dateTime.toDateTime(DateTimeZone.UTC); //store as UTC
            dataOutput.writeLong(dateTime.getMillis());
        }

        @Override
        public Object deserialize(DataInput dataInput) {
View Full Code Here

    protected static class DateTimeFormatter implements ValueFormatter {
        @Override
        public String format(Object value, ValueType valueType, FormatContext formatCtx) throws InterruptedException {
            DateTime dateTime = (DateTime)value;
            return dateTime.toDateTime(DateTimeZone.UTC).toString();
        }
    }

    protected static class AllFormatter implements ValueFormatter {
        @Override
View Full Code Here

      DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime());
      if (out == null) {
        return null;
      }
     
      return out.toDateTime();
    } catch (Exception e) {
      throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value));
    }
  }
}
View Full Code Here

   */
  @Test
  public void testWriteTimestamp() throws Exception {
    DateTime d = new DateTime(1991,10,11,14,23,30, 10);//uses default TZ
    pigValueRangeTest("junitTypeTest1", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.plusHours(2);
    pigValueRangeTest("junitTypeTest2", "timestamp", "datetime", HCatBaseStorer.OOR_VALUE_OPT_VALUES.Null,
      d.toString(), d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.toDateTime(DateTimeZone.UTC);
    pigValueRangeTest("junitTypeTest3", "timestamp", "datetime", null, d.toString(),
View Full Code Here

    DateTime d = new DateTime(1991,10,11,14,23,30, 10);//uses default TZ
    pigValueRangeTest("junitTypeTest1", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.plusHours(2);
    pigValueRangeTest("junitTypeTest2", "timestamp", "datetime", HCatBaseStorer.OOR_VALUE_OPT_VALUES.Null,
      d.toString(), d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.toDateTime(DateTimeZone.UTC);
    pigValueRangeTest("junitTypeTest3", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());

    d = new DateTime(1991,10,11,23,24,25, 26);
View Full Code Here

    pigValueRangeTest("junitTypeTest1", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.plusHours(2);
    pigValueRangeTest("junitTypeTest2", "timestamp", "datetime", HCatBaseStorer.OOR_VALUE_OPT_VALUES.Null,
      d.toString(), d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.toDateTime(DateTimeZone.UTC);
    pigValueRangeTest("junitTypeTest3", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());

    d = new DateTime(1991,10,11,23,24,25, 26);
    pigValueRangeTest("junitTypeTest1", "timestamp", "datetime", null, d.toString(),
View Full Code Here

    d = d.plusHours(2);
    pigValueRangeTest("junitTypeTest2", "timestamp", "datetime", HCatBaseStorer.OOR_VALUE_OPT_VALUES.Null,
      d.toString(), d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.toDateTime(DateTimeZone.UTC);
    pigValueRangeTest("junitTypeTest3", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());

    d = new DateTime(1991,10,11,23,24,25, 26);
    pigValueRangeTest("junitTypeTest1", "timestamp", "datetime", null, d.toString(),
      d.toDateTime(DateTimeZone.getDefault()).toString());
    d = d.toDateTime(DateTimeZone.UTC);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.