org.fujion.common.DateUtil.toDate()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.fujion.common.DateUtil.toDate()方法的一些代码示例,展示了DateUtil.toDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.toDate()方法的具体详情如下:
包路径:org.fujion.common.DateUtil
类名称:DateUtil
方法名:toDate

DateUtil.toDate介绍

[英]Converts day, month, and year to a date.
[中]将日、月和年转换为日期。

代码示例

代码示例来源:origin: org.fujion/fujion-common

/**
 * Converts day, month, and year to a date.
 *
 * @param day Day of month.
 * @param month Month (1=January, etc.)
 * @param year Year (4 digit).
 * @return Date instance.
 */
public static Date toDate(int day, int month, int year) {
  return toDate(day, month, year, 0, 0, 0);
}

代码示例来源:origin: org.fujion/fujion-common

@Test
public void testDateRange() {
  DateRange dr = new DateRange("test|12-Jul-2010|15-Aug-2010");
  assertEquals(dr.getStartDate(), DateUtil.toDate(12, 7, 2010));
  assertEquals(dr.getEndDate(), DateUtil.toDate(15, 8, 2010));
  assertTrue(dr.inRange(DateUtil.toDate(1, 8, 2010)));
  assertFalse(dr.inRange(DateUtil.toDate(15, 8, 2010)));
  assertTrue(dr.inRange(DateUtil.toDate(15, 8, 2010), true, true));
  assertFalse(dr.inRange(DateUtil.toDate(15, 8, 2010, 13, 30, 0), true, true));
  assertFalse(dr.inRange(DateUtil.toDate(16, 8, 2010), true, true));
}

代码示例来源:origin: org.fujion/fujion-common

@Test
public void testAge() {
  Date dob = DateUtil.toDate(27, 7, 1958);
  Date ref = DateUtil.toDate(1, 1, 2013);
  assertEquals("54 yrs", DateUtil.formatAge(dob, true, ref));
  assertEquals("54 yr", DateUtil.formatAge(dob, false, ref));
  dob = DateUtil.toDate(15, 12, 2012);
  assertEquals("17 days", DateUtil.formatAge(dob, true, ref));
  dob = DateUtil.toDate(30, 10, 2012);
  assertEquals("2 mos", DateUtil.formatAge(dob, true, ref));
}

相关文章