Example usage for java.sql Date valueOf

List of usage examples for java.sql Date valueOf

Introduction

In this page you can find the example usage for java.sql Date valueOf.

Prototype

@SuppressWarnings("deprecation")
public static Date valueOf(LocalDate date) 

Source Link

Document

Obtains an instance of Date from a LocalDate object with the same year, month and day of month value as the given LocalDate .

Usage

From source file:adalid.core.AbstractDataArtifact.java

private Date someDateValue(Field field, String string) {
    if (StringUtils.isBlank(string)) {
        return null;
    }//from  w w  w  .  j  a va 2s  . c o  m
    Date someRelativeDate = someRelativeDateValue(string);
    if (someRelativeDate != null) {
        return someRelativeDate;
    }
    try {
        return Date.valueOf(string);
    } catch (Exception e) {
        logInvalidDataExpression(field, "date", e);
    }
    return null;
}

From source file:com.redhat.rhn.manager.system.SystemManager.java

/**
 * Return a note by ID and Server ID/* w  ww  . j  a  va  2 s . co m*/
 * @param user User to use to do the lookups
 * @param nid note ID
 * @param sid server ID
 * @return Note object
 */
public static Note lookupNoteByIdAndSystem(User user, Long nid, Long sid) {
    SelectMode m = ModeFactory.getMode("System_queries", "note_by_id_and_server");
    Note n = new Note();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("nid", nid);
    params.put("sid", sid);
    DataResult<Map<String, Object>> dr = m.execute(params);
    for (Map<String, Object> map : dr) {
        n.setCreator(UserManager.lookupUser(user, (Long) map.get("creator")));
        n.setId((Long) map.get("id"));
        n.setServer(lookupByIdAndUser((Long) map.get("server_id"), user));
        n.setSubject((String) map.get("subject"));
        n.setNote((String) map.get("note"));
        n.setModified(Date.valueOf((String) map.get("modified")));
    }
    return n;
}