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:de.interseroh.report.formatters.TimestampFormatter.java

@Override
public Timestamp parse(String text, Locale locale) throws ParseException {
    java.util.Date parsed = getDateFormat(locale).parse(text);
    return new Timestamp(parsed.getTime());
}

From source file:com.josue.lottery.eap.persistence.entity.rest.Resource.java

@PrePersist
public void generateUuid() {
    if (StringUtils.isBlank(uuid)) {
        this.uuid = UUID.randomUUID().toString();
        this.dateCreated = new Timestamp(new Date().getTime());
    } else {/*from   w  ww.j  a  va  2s  .  c  om*/
        this.dateUpdated = new Timestamp(new Date().getTime());
    }
}

From source file:mtsar.api.csv.WorkerCSV.java

public static Iterator<Worker> parse(Stage stage, CSVParser csv) {
    final Set<String> header = csv.getHeaderMap().keySet();
    checkArgument(!Sets.intersection(header, Sets.newHashSet(HEADER)).isEmpty(), "Unknown CSV header: %s",
            String.join(",", header));

    return StreamSupport.stream(csv.spliterator(), false).map(row -> {
        final String id = row.isSet("id") ? row.get("id") : null;
        final String[] tags = row.isSet("tags") && !StringUtils.isEmpty(row.get("tags"))
                ? row.get("tags").split("\\|")
                : new String[0];
        final String datetime = row.isSet("datetime") ? row.get("datetime") : null;

        return new Worker.Builder().setId(StringUtils.isEmpty(id) ? null : Integer.valueOf(id))
                .setStage(stage.getId()).addAllTags(Arrays.asList(tags))
                .setDateTime(new Timestamp(StringUtils.isEmpty(datetime) ? System.currentTimeMillis()
                        : Long.parseLong(datetime) * 1000L))
                .build();/*ww  w  .ja  v a  2s. c o  m*/
    }).iterator();
}

From source file:com.bitranger.parknshop.task.OrderChecker.java

private static Timestamp subtract(Timestamp left, Timestamp right) {
    return new Timestamp(left.getTime() - right.getTime());
}

From source file:com.springmvc.dao.TimeLogDAO.java

public void updateLogout(TimeLog timeLog) {
    TimeLog timeLogToUpdate = getTimeLog(timeLog.getId());

    Date date = new Date();
    Timestamp time = new Timestamp(date.getTime());
    timeLogToUpdate.setLogout(time);/* w ww.  j  a  va2s . c  o  m*/

    Timestamp login = timeLogToUpdate.getLogin();
    long diff = Math.abs(login.getTime() - time.getTime());

    long second = (diff / 1000) % 60;
    long minute = (diff / (1000 * 60)) % 60;
    long hour = (diff / (1000 * 60 * 60)) % 24;
    long day = (diff / (1000 * 60 * 60 * 24));
    String toString = String.format("%02dd:%02dh:%02dm:%02ds", day, hour, minute, second, diff);
    timeLogToUpdate.setDuration(toString);

    getCurrentSession().update(timeLogToUpdate);
}

From source file:cherry.foundation.type.jdbc.CustomBeanPropertySqlParameterSource.java

@Override
public Object getValue(String paramName) throws IllegalArgumentException {
    Object object = super.getValue(paramName);
    if (object instanceof LocalDateTime) {
        LocalDateTime ldt = (LocalDateTime) object;
        return new Timestamp(ldt.toDate().getTime());
    }//from  w w  w .j  a  v a  2  s. c o m
    if (object instanceof LocalDate) {
        LocalDate ld = (LocalDate) object;
        return new Date(ld.toDate().getTime());
    }
    if (object instanceof LocalTime) {
        LocalTime lt = (LocalTime) object;
        return new Time((long) lt.getMillisOfDay());
    }
    if (object instanceof SecureType<?>) {
        SecureType<?> st = (SecureType<?>) object;
        return st.crypto();
    }
    if (object instanceof Code<?>) {
        Code<?> ce = (Code<?>) object;
        return ce.code();
    }
    return object;
}

From source file:com.daon.identityx.entity.Session.java

public Session(Account user, long sessionPeriod) {
    this.accountId = user.getId();
    this.createdDTM = new Timestamp(System.currentTimeMillis());
    this.expiringDTM = new Timestamp(System.currentTimeMillis() + sessionPeriod);
}

From source file:com.recomdata.grails.rositaui.etl.dao.ValidationErrorBatchPreparedStatementSetter.java

@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
    ValidationError v = items.get(i);/*from w  w  w . j  a v  a 2  s .c  o  m*/
    ps.setString(1, v.getType());
    ps.setLong(2, v.getLineNumber());
    ps.setString(3, v.getMessage());
    ps.setTimestamp(4, new Timestamp(v.getDate().getTime()));
    ps.setString(5, v.getSchema());
    ps.setString(6, v.getLocation());
    ps.setString(7, v.getSourceType());
    ps.setString(8, v.getFilename());
}

From source file:airport.services.chat.ServiceChatBasic.java

@Override
public void addMessage(User user, String text) {
    if (text == null || text.isEmpty()) {
        return;/*from   ww  w  . j a va2 s. c o  m*/
    }

    serviceStatistics.incAmountSendMessage(user);
    CHAT_DAO.addMessage(user, text, new Timestamp(new Date().getTime()));

    if (LOG.isInfoEnabled()) {
        LOG.info("add message");
    }
}

From source file:org.uaa.security.core.LoggerManager.java

public void logBefore(HttpServletRequest request) {
    res_uri = request.getPathInfo();/*  w  w w .j  a v  a  2 s .  c om*/
    if (res_uri.startsWith("/logs"))
        return;

    String res_action = request.getMethod();
    request_time = new Timestamp(System.currentTimeMillis());
    String addr = request.getRemoteAddr();
    String client = request.getHeader("User-Agent");

    log = new Apilog();
    log.setAddr(addr);
    log.setClient(client);
    log.setRequest_time(request_time.getTime());
    log.setRes_action(res_action);
    log.setRes_uri(res_uri);

    securityService.insertLog(log);
}