Example usage for java.sql Timestamp Timestamp

List of usage examples for java.sql Timestamp Timestamp

Introduction

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

Prototype

public Timestamp(long time) 

Source Link

Document

Constructs a Timestamp object using a milliseconds time value.

Usage

From source file:com.awcoleman.ExampleJobSummaryLogWithOutput.utility.CreateBinaryDatafile.java

public String generateDatetime() {
    long offset = Timestamp.valueOf("2015-02-21 00:00:00").getTime();
    long end = Timestamp.valueOf("2015-02-24 00:00:00").getTime();
    long diff = end - offset + 1;
    Timestamp rand = new Timestamp(offset + (long) (Math.random() * diff));

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmss.SSS");

    return sdf.format(rand);
}

From source file:com.ex.dao.impl.TestGroupDaoImpl.java

@Before
public void setUp() {
    group = new Group();
    XStream xstream = new XStream();
    group.setId("GRP_1");
    group.setVersion(0l);//  w w  w .j a v  a 2  s.  c  o m
    group.setGroupName("FirstGroup");
    group.setCreatedBy("John Doe");
    group.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
    String xml = xstream.toXML(group);
    group.setXml(xml);
    groupDao.saveGroup(group);
}

From source file:org.cloudfoundry.identity.uaa.audit.JdbcAuditService.java

@Override
public List<AuditEvent> find(String principal, long after) {
    return template.query(
            "select event_type, principal_id, origin, event_data, created from sec_audit where "
                    + "principal_id=? and created > ? order by created desc",
            new AuditEventRowMapper(), principal, new Timestamp(after));
}

From source file:com.multimedia.service.wallpaper.comment.CmsWallpaperCommentService.java

@Override
public WallpaperComment getInsertBean(WallpaperComment obj) {
    if (obj == null)
        obj = new WallpaperComment();
    obj.setCreationTime(new Timestamp(System.currentTimeMillis()));
    return obj;/*from  w w  w  . j  av a  2s  .  c  o m*/
}

From source file:com.silverpeas.gallery.dao.OrderDAO.java

/**
 * Persists a new order./*from  w  ww  . j  av  a2s.com*/
 * @param con
 * @param basket
 * @param userId
 * @param instanceId
 * @return the identifier of the new order.
 * @throws SQLException
 * @throws UtilException
 */
public static String createOrder(Connection con, Collection<String> basket, String userId, String instanceId)
        throws SQLException, UtilException {

    // New order
    String uuid = getUniqueId();
    executeUpdate(con,
            "insert into SC_Gallery_Order (orderId, userId, instanceId, createDate) values (?,?,?,?)", uuid,
            userId, instanceId, new Timestamp(new Date().getTime()));

    // Details of the order
    for (String mediaId : basket) {
        addOrderMedia(con, mediaId, uuid, instanceId);
    }

    return uuid;
}

From source file:org.uaa.admin.resource.Apilogs.java

@Path("/addrs")
@GET/*  w  ww  .ja v  a 2s.  c o m*/
public String getUniqueAddrCount(@QueryParam("interval") Integer interval) {
    if (interval == null)
        interval = default_interval;

    Timestamp now = new Timestamp(System.currentTimeMillis());
    Integer count = apilogService.getUniqueAddrCount(interval, now.getTime());

    Map<String, Object> attrs = new LinkedHashMap<String, Object>();
    attrs.put("count", count);

    ResponseWithData res = new ResponseWithData(attrs);
    return res.toJson();
}

From source file:chalk.domain.Message.java

public Message(User sender, User receiver, String text) {
    this.sender = sender;
    this.receiver = receiver;
    this.text = text;
    java.util.Date now = new java.util.Date();
    this.timeSent = new Timestamp(now.getTime());
}

From source file:com.wavemaker.commons.json.deserializer.WMDateDeSerializer.java

public static Date getDate(String value) {
    if (StringUtils.isBlank(value)) {
        return null;
    }//  ww w  .  java 2 s  . c om
    try {
        Date parsedDate = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT).parse(value);
        return new Timestamp(parsedDate.getTime());
    } catch (ParseException e) {
        logger.trace("{} is not in the expected date time format {}", value, DEFAULT_DATE_TIME_FORMAT);
    }
    try {
        Date parsedDate = new SimpleDateFormat(DEFAULT_DATE_FORMAT).parse(value);
        return new java.sql.Date(parsedDate.getTime());
    } catch (ParseException e) {
        logger.trace("{} is not in the expected date format {}", value, DEFAULT_DATE_FORMAT);
    }
    try {
        Date parsedDate = new SimpleDateFormat(DEFAULT_TIME_FORMAT).parse(value);
        return new Time(parsedDate.getTime());
    } catch (ParseException e) {
        logger.trace("{} is not in the expected time format {}", value, DEFAULT_TIME_FORMAT);
    }
    throw new WMRuntimeException("Failed to parse the string " + value + "as java.util.Date");
}

From source file:com.liusoft.dlog4j.SessionUserObject.java

/**
 * PO??//from w ww . j  a v  a2  s  .c  om
 * @param bean
 * @return
 */
public static SessionUserObject copyFrom(UserBean bean) {
    SessionUserObject user = new SessionUserObject();
    user.setId(bean.getId());
    user.setName(bean.getName());
    user.setNickname(bean.getNickname());
    user.setSex(bean.getSex());
    if (bean.getBirth() != null)
        user.setBirth((Date) bean.getBirth().clone());
    if (bean.getContactInfo() != null)
        user.setContactInfo((ContactInfo) bean.getContactInfo().clone());
    if (bean.getCount() != null)
        user.setCount((CountInfo) bean.getCount().clone());
    user.setResume(bean.getResume());
    user.setRegTime(new Timestamp(bean.getRegTime().getTime()));
    if (bean.getLastTime() != null)
        user.setLastTime(new Timestamp(bean.getLastTime().getTime()));
    user.setLastAddr(bean.getLastAddr());
    user.setStatus(bean.getStatus());
    user.setKeepDays(bean.getKeepDays());
    user.setOwnSiteId(bean.getOwnSiteId());
    user.setPortrait(bean.getPortrait());
    user.setRole(bean.getRole());
    return user;
}

From source file:org.apache.niolex.config.dao.impl.ItemDaoImpl.java

/**
 * Override super method//from   www .  ja va2 s.c  om
 * @see org.apache.niolex.config.dao.ItemDao#loadAllConfigItems(long)
 */
@Override
public List<ConfigItem> loadAllConfigItems(long startTime) {
    final String sql = "select groupid, ckey, value, curid, uurid, updatetime from config_info where updatetime >= ? order by groupid";
    return template.query(sql, new Object[] { new Timestamp(startTime) }, ConfigItemRowMapper.INSTANCE);
}