Package fi.luomus.commons.containers

Examples of fi.luomus.commons.containers.DateValue


    public void test_format_datevalue() {
      assertEquals("2013-01-15", DateUtils.format(new DateValue("15", "1", "2013"), "yyyy-MM-dd"));
    }

    public void test___day_of_year() {
      assertEquals(1, DateUtils.getDayOfYear(new DateValue("1", "1", "2011")));
      assertEquals(2, DateUtils.getDayOfYear(new DateValue("2", "1", "2011")));
      assertEquals(31, DateUtils.getDayOfYear(new DateValue("31", "1", "2011")));
      assertEquals(32, DateUtils.getDayOfYear(new DateValue("1", "2", "2011")));
      assertEquals(365, DateUtils.getDayOfYear(new DateValue("31", "12", "2011")));
      assertEquals(366, DateUtils.getDayOfYear(new DateValue("31", "12", "2012"))); // 2012 is leap year
      try {
        DateUtils.getDayOfYear(new DateValue("32", "1", "2011"));
        fail();
      } catch (IllegalArgumentException e) {}
      try {
        DateUtils.getDayOfYear(new DateValue("29", "2", "2011")); // feb has 28 days in 2011
        fail();
      } catch (IllegalArgumentException e) {}
    }
View Full Code Here


    date = Utils.removeWhitespace(date);
    String[] dates = dotSplit(date);
    if (dates.length < 1) return DateValue.EMPTY_DATE;
    String day = ""; String month = ""; String year = "";
    day = addFrontZeroIfNeeded(dates[0]);
    if (dates.length < 2) return new DateValue(day, month, year);
    month = addFrontZeroIfNeeded(dates[1]);
    if (dates.length < 3) return new DateValue(day, month, year);
    year = removeFrontZeros(dates[2]);
    return new DateValue(day, month, year);
  }
View Full Code Here

    days = days - months*30;
    if (months == 12) {
      months = 0;
      years++;
    }
    return new DateValue(days, months, years);
  }
View Full Code Here

TOP

Related Classes of fi.luomus.commons.containers.DateValue

Copyright © 2018 www.massapicom. 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.