当前位置: 首页>>代码示例>>Java>>正文


Java Date.valueOf方法代码示例

本文整理汇总了Java中java.sql.Date.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Date.valueOf方法的具体用法?Java Date.valueOf怎么用?Java Date.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.Date的用法示例。


在下文中一共展示了Date.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stringToDate

import java.sql.Date; //导入方法依赖的package包/类
public static Date stringToDate(String str, String pattern) {
    Date date = null;
    try {
        date = Date.valueOf(str);
    } catch (Exception e) {
        throw new IllegalArgumentException("'" + str + "' is not a valid date of pattern '" + pattern + "'", e);
    }
    return date;
}
 
开发者ID:jenkin2016,项目名称:solr-sql,代码行数:10,代码来源:DateFormat.java

示例2: test00

import java.sql.Date; //导入方法依赖的package包/类
@Test(dataProvider = "validDateValues")
public void test00(String d, String expectedD) {
    Date d1 = Date.valueOf(d);
    Date d2 = Date.valueOf(expectedD);
    assertTrue(d1.equals(d2) && d2.equals(d1)
            && d1.toString().equals(expectedD), "Error d1 != d2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DateTests.java

示例3: getBirthday

import java.sql.Date; //导入方法依赖的package包/类
/**
 * Gets birthday from contacts database cursor object
 * @param c cursor for the contact
 * @return birthday or null, if birthday column is empty or
 * the value can't be parsed into valid date object
 */
private Date getBirthday(Cursor c) {

    try {
        int colBirthday = c.getColumnIndexOrThrow(CommonDataKinds.Event.START_DATE);
        return Date.valueOf(c.getString(colBirthday));
    } catch (IllegalArgumentException e) {
        LOG.e(LOG_TAG, "Failed to get birthday for contact from cursor", e);
        return null;
    }
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:17,代码来源:ContactAccessorSdk5.java

示例4: tableChanged

import java.sql.Date; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
	int row=e.getFirstRow();
	int userId=Integer.parseInt(table.getValueAt(row, 0).toString());
	String userName=table.getValueAt(row, 1).toString();
	String pwdString=table.getValueAt(row, 2).toString();
	//String IP=table.getValueAt(row, 3).toString();
	//String state=table.getValueAt(row, 4).toString();
	String userGender=table.getValueAt(row, 5).toString();
	String userEmail=table.getValueAt(row, 6).toString();
	//String userSignature=table.getValueAt(row, 5).toString();
	Date userBirthday=Date.valueOf(table.getValueAt(row, 9).toString());
	Users user=new Users(userId,userName,pwdString, userGender, userEmail,userBirthday);
	UserDao userDao=new UserDao();
	try {
		if(userDao.update(user))
		{
			JOptionPane.showMessageDialog(null, "修改成功!");
		}
		else {
			JOptionPane.showMessageDialog(null, "修改失败!");
		}
	} catch (HeadlessException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	
}
 
开发者ID:sxei,项目名称:myqq,代码行数:28,代码来源:UserTableCahnged.java

示例5: getD

import java.sql.Date; //导入方法依赖的package包/类
public Date getD(String key) {
    if (this == null) {
        return null;
    }
    String output = get(key);
    if (output == null || output.equals("")) {
        return null;
    }
    try {
        return Date.valueOf(output);
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:Doc.java

示例6: getPredicateForDate

import java.sql.Date; //导入方法依赖的package包/类
/**
 * Get the correct predicate for Date objects.
 *
 * @param op the specified predicate operation
 * @param initialValue the initial value, to be checked against, for the predicate
 * @return the predicate with correct operation and specified initial value
 */
public static Predicate getPredicateForDate(final TypePredicateOp op, final Object initialValue) {
  Predicate predicate = null;
  Date dateValue = initialValue instanceof Date ? (Date) initialValue
      : Date.valueOf(String.valueOf(initialValue));
  switch ((CompareOp) op) {
    case LESS:
      predicate = isLessThan(dateValue);
      break;
    case LESS_OR_EQUAL:
      predicate = isLessThanOrEqual(dateValue);
      break;
    case GREATER:
      predicate = isGreaterThan(dateValue);
      break;
    case GREATER_OR_EQUAL:
      predicate = isGreaterThanOrEqual(dateValue);
      break;
    case EQUAL:
      predicate = isEqual(dateValue);
      break;
    case NOT_EQUAL:
      predicate = isNotEqual(dateValue);
      break;
  }
  return predicate;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:34,代码来源:MPredicateHelper.java

示例7: test01

import java.sql.Date; //导入方法依赖的package包/类
@Test
public void test01() {
    Date d = Date.valueOf("1961-08-30");
    assertFalse(d.after(d), "Error d.after(d) = true");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:DateTests.java

示例8: test

import java.sql.Date; //导入方法依赖的package包/类
@Test(dataProvider = "invalidDateValues",
        expectedExceptions = IllegalArgumentException.class)
public void test(String d) throws Exception {
    Date.valueOf(d);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:DateTests.java

示例9: deserialize

import java.sql.Date; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonElement json, Type typeOfT,
                        JsonDeserializationContext context) throws JsonParseException {
    return json == null ? null : Date.valueOf(json.getAsString());
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:6,代码来源:GsonTypeConverters.java

示例10: test2

import java.sql.Date; //导入方法依赖的package包/类
@Test
public void test2() {
    Date d = Date.valueOf("1961-08-30");
    Date d2 = new Date(System.currentTimeMillis());
    assertTrue(d2.after(d), "Error d2.after(d) = false");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:DateTests.java

示例11: test9

import java.sql.Date; //导入方法依赖的package包/类
@Test
public void test9() {
    Date d = Date.valueOf("1961-08-30");
    assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:DateTests.java

示例12: test21

import java.sql.Date; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test21() throws Exception {
    Date d = Date.valueOf("1961-08-30");
    d.getHours();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:DateTests.java

示例13: test17

import java.sql.Date; //导入方法依赖的package包/类
@Test
public void test17() {
    Date d = Date.valueOf("1961-08-30");
    Date d2 = Date.valueOf(d.toString());
    assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:DateTests.java

示例14: toDate

import java.sql.Date; //导入方法依赖的package包/类
private static Date toDate(Object x) {
  if (x instanceof String) {
    return Date.valueOf((String) x);
  }
  return new Date(toLong(x));
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:7,代码来源:AvaticaSite.java

示例15: test6

import java.sql.Date; //导入方法依赖的package包/类
@Test
public void test6() {
    Date d = Date.valueOf("1961-08-30");
    Date d2 = new Date(System.currentTimeMillis());
    assertTrue(d.before(d2), "Error d.before(d2) = false");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:DateTests.java


注:本文中的java.sql.Date.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。