Example usage for java.util Calendar setTimeInMillis

List of usage examples for java.util Calendar setTimeInMillis

Introduction

In this page you can find the example usage for java.util Calendar setTimeInMillis.

Prototype

public void setTimeInMillis(long millis) 

Source Link

Document

Sets this Calendar's current time from the given long value.

Usage

From source file:com.wabacus.system.datatype.CDateType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date cdd = rs.getDate(column);
    if (cdd == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cdd.getTime());
    return cd;//from   ww w  .j ava 2s . co  m
}

From source file:com.wabacus.system.datatype.CDateType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date cdd = rs.getDate(iindex);
    if (cdd == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cdd.getTime());
    return cd;/*  w  ww .  j  av  a2s  .c om*/
}

From source file:com.wabacus.system.datatype.CTimestampType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Timestamp cts = rs.getTimestamp(column);
    if (cts == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cts.getTime());
    return cd;//w  w w  .j a  v a 2s  .c om
}

From source file:com.wabacus.system.datatype.CTimestampType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Timestamp cts = rs.getTimestamp(iindex);
    if (cts == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cts.getTime());
    return cd;/*from   w ww  . j av  a2  s. c o  m*/
}

From source file:com.wabacus.system.datatype.CTimeType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Time ctt = rs.getTime(column);
    if (ctt == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(ctt.getTime());
    return cd;//from w  ww .java2s .c  o m
}

From source file:com.wabacus.system.datatype.CTimeType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Time ctt = rs.getTime(iindex);
    if (ctt == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(ctt.getTime());
    return cd;/*w  w  w. j a v  a2 s  .c  om*/
}

From source file:org.openhie.openempi.util.DateConverterTest.java

public void testConvertStringToTimestamp() throws Exception {
    Date today = new Date();
    Calendar todayCalendar = new GregorianCalendar();
    todayCalendar.setTime(today);//from www .j a  v a  2s.  com
    String datePart = DateUtil.convertDateToString(today);

    Timestamp time = (Timestamp) converter.convert(Timestamp.class, datePart + " 01:02:03.4");
    Calendar cal = new GregorianCalendar();
    cal.setTimeInMillis(time.getTime());
    assertEquals(todayCalendar.get(Calendar.YEAR), cal.get(Calendar.YEAR));
    assertEquals(todayCalendar.get(Calendar.MONTH), cal.get(Calendar.MONTH));
    assertEquals(todayCalendar.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH));
}

From source file:babel.prep.datedcorpus.DatedLangFilesOutputFormat.java

protected String generateFileNameForKeyValue(Text key, Text ver, String name) {
    String toks[] = key.toString().split(DatedCorpusGenMapper.DATE_LANG_SEP);

    if (toks == null || toks.length != 2) {
        return REJECTED_FILE;
    } else {//from w ww  .  ja v a2 s.com
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(Long.parseLong(toks[1]));

        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        int day = cal.get(Calendar.DAY_OF_MONTH);

        if (year < 2000 || year > 2011) {
            return REJECTED_FILE;
        } else {
            return toks[0] + File.separator + year + File.separator + year + "-" + month + "-" + day
                    + EXTENSION;
        }
    }
}

From source file:controller.OrderManagerController.java

@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
public String editOrder(ModelMap mm, @PathVariable(value = "id") int id) {
    Order od = orderModel.getByID(id);//from ww w. ja v a  2s.  c o m
    if (od != null) {
        Customer cus = customerModel.getByID(od.getCustomer().getCustomerId());
        long crDate = od.getOrderPaymentDate().getTime();
        long exDate = od.getOrderExpiredDate().getTime();
        Calendar month = Calendar.getInstance();
        month.setTimeInMillis(exDate - crDate);

        mm.put("month", month.get(Calendar.MONTH));
        mm.put("customer", cus);
        mm.addAttribute("order", od);
    }
    return "editOrder";
}

From source file:it.geosolutions.opensdi2.session.impl.UserSessionImpl.java

@Override
public void refresh() {
    if (expiration != null) {
        Calendar newExpiration = Calendar.getInstance();
        newExpiration.setTimeInMillis(newExpiration.getTimeInMillis() + expirationInterval);
        setExpiration(newExpiration);//from  www. ja  va2 s .  c  o  m
    }

}