本文整理了Java中java.sql.Date.getDate()
方法的一些代码示例,展示了Date.getDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.getDate()
方法的具体详情如下:
包路径:java.sql.Date
类名称:Date
方法名:getDate
暂无
代码示例来源:origin: apache/drill
@Override
Date transform(final Date value) {
int year = maskedYearValue == UNMASKED_VAL ? value.getYear() : maskedYearValue;
int month = maskedMonthValue == UNMASKED_VAL ? value.getMonth() : maskedMonthValue;
int day = maskedDayValue == UNMASKED_VAL ? value.getDate() : maskedDayValue;
return new Date(year, month, day);
}
代码示例来源:origin: robovm/robovm
/**
* Produces a string representation of the date in SQL format
*
* @return a string representation of the date in SQL format - {@code "yyyy-MM-dd"}.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(10);
format((getYear() + 1900), 4, sb);
sb.append('-');
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 2, sb);
return sb.toString();
}
代码示例来源:origin: Impetus/Kundera
/**
* Test method for {@link com.impetus.kundera.property.accessor.SQLDateAccessor#fromString(java.lang.Class, java.lang.String)}.
*/
@Test
public void testFromString()
{
Assert.assertNull(accessor.fromString(Date.class, null));
long l = System.currentTimeMillis();
Date d = new Date(l);
Date d2 = accessor.fromString(Date.class, "" + l);
Assert.assertEquals(d, d2);
Assert.assertEquals(d.getYear(), accessor.fromString(Date.class, d2.toString()).getYear());
Assert.assertEquals(d.getMonth(), accessor.fromString(Date.class, d2.toString()).getMonth());
Assert.assertEquals(d.getDate(), accessor.fromString(Date.class, d2.toString()).getDate());
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeWithOrClause()
{
EntityManager em;
String query;
Query q;
List<StudentSqlDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentSqlDate s where s.name = 'Kuldeep' and s.age > " + getMinValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentSqlDate student : students)
{
Assert.assertEquals(((Date) getMaxValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getMaxValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getMaxValue()).getMonth(), student.getId().getMonth());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
private void findByAge()
{
EntityManager em;
String query;
Query q;
List<StudentSqlDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentSqlDate s where s.age = " + getRandomValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentSqlDate student : students)
{
Assert.assertEquals(((Date) getRandomValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getRandomValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getRandomValue()).getMonth(), student.getId().getMonth());
Assert.assertEquals(getRandomValue(short.class), student.getAge());
Assert.assertEquals(getRandomValue(String.class), student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeGTAndLTEQ()
{
EntityManager em;
String query;
Query q;
List<StudentSqlDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentSqlDate s where s.name = 'Kuldeep' and s.age > " + getMinValue(short.class)
+ " and s.age <= " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentSqlDate student : students)
{
Assert.assertEquals(((Date) getMaxValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getMaxValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getMaxValue()).getMonth(), student.getId().getMonth());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeGTAndLT()
{
EntityManager em;
String query;
Query q;
List<StudentSqlDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentSqlDate s where s.name = 'Amresh' and s.age > " + getMinValue(short.class)
+ " and s.age < " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentSqlDate student : students)
{
Assert.assertEquals(((Date) getRandomValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getRandomValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getRandomValue()).getMonth(), student.getId().getMonth());
Assert.assertEquals(getRandomValue(short.class), student.getAge());
Assert.assertEquals(getRandomValue(String.class), student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAGEBetween()
{
EntityManager em;
String query;
Query q;
List<StudentSqlDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentSqlDate s where s.name = 'Amresh' and s.age between " + getMinValue(short.class)
+ " and " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentSqlDate student : students)
{
Assert.assertEquals(((Date) getRandomValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getRandomValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getRandomValue()).getMonth(), student.getId().getMonth());
Assert.assertEquals(getRandomValue(short.class), student.getAge());
Assert.assertEquals(getRandomValue(String.class), student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(((Date) getMinValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getMinValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getMinValue()).getMonth(), student.getId().getMonth());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(((Date) getMinValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getMinValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getMinValue()).getMonth(), student.getId().getMonth());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(joiningDateAndTime.getSeconds(), s.getJoiningDateAndTime().getSeconds());
Assert.assertEquals(newSqlDate.getDate(), s.getSqlDate().getDate());
Assert.assertEquals(newSqlDate.getMonth(), s.getSqlDate().getMonth());
Assert.assertEquals(newSqlDate.getYear(), s.getSqlDate().getYear());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(((Date) getRandomValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getRandomValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getRandomValue()).getMonth(), student.getId().getMonth());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(joiningDateAndTime.getSeconds(), s.getJoiningDateAndTime().getSeconds());
Assert.assertEquals(newSqlDate.getDate(), s.getSqlDate().getDate());
Assert.assertEquals(newSqlDate.getMonth(), s.getSqlDate().getMonth());
Assert.assertEquals(newSqlDate.getYear(), s.getSqlDate().getYear());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(joiningDateAndTime.getSeconds(), s.getJoiningDateAndTime().getSeconds());
Assert.assertEquals(newSqlDate.getDate(), s.getSqlDate().getDate());
Assert.assertEquals(newSqlDate.getMonth(), s.getSqlDate().getMonth());
Assert.assertEquals(newSqlDate.getYear(), s.getSqlDate().getYear());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(joiningDateAndTime.getSeconds(), s.getJoiningDateAndTime().getSeconds());
Assert.assertEquals(newSqlDate.getDate(), s.getSqlDate().getDate());
Assert.assertEquals(newSqlDate.getMonth(), s.getSqlDate().getMonth());
Assert.assertEquals(newSqlDate.getYear(), s.getSqlDate().getYear());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(((Date) getRandomValue()).getDate(), student.getId().getDate());
Assert.assertEquals(((Date) getRandomValue()).getYear(), student.getId().getYear());
Assert.assertEquals(((Date) getRandomValue()).getMonth(), student.getId().getMonth());
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings("deprecation")
private Date withTZ(Date date, Calendar cal) {
if (date == null)
return null;
int year = date.getYear() + 1900;
int month = date.getMonth();
int day = date.getDate();
return new Date(getMillis(cal, year, month, day, 0, 0, 0, 0));
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code java.sql.Date} to a {@code LocalDate}.
*
* @param sqlDate the SQL date, not null
* @return the local date, not null
*/
@SuppressWarnings("deprecation")
public static LocalDate toLocalDate(java.sql.Date sqlDate) {
return LocalDate.of(sqlDate.getYear() + 1900, sqlDate.getMonth() + 1, sqlDate.getDate());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code java.sql.Date} to a {@code LocalDate}.
*
* @param sqlDate the SQL date, not null
* @return the local date, not null
*/
@SuppressWarnings("deprecation")
public static LocalDate toLocalDate(java.sql.Date sqlDate) {
return LocalDate.of(sqlDate.getYear() + 1900, sqlDate.getMonth() + 1, sqlDate.getDate());
}
代码示例来源:origin: cascading/lingual-core
@Test
public void testFromCanonical()
{
Date coerced = (Date) sqlDateCoercibleType.coerce( getIntegerRepresentation().intValue(), java.sql.Date.class );
assertEquals( "wrong year", inputDate.getYear(), coerced.getYear() );
assertEquals( "wrong month", inputDate.getMonth(), coerced.getMonth() );
assertEquals( "wrong day of month", inputDate.getDate(), coerced.getDate() );
}
内容来源于网络,如有侵权,请联系作者删除!