Java Timestamp Create toTimestamp(final Calendar cal)

Here you can find the source of toTimestamp(final Calendar cal)

Description

Converts a Calendar into a SQL timestamp.

License

Open Source License

Parameter

Parameter Description
cal Calendar to convert.

Return

Equivalent timestamp.

Declaration

public static Timestamp toTimestamp(final Calendar cal) 

Method Source Code


//package com.java2s;
/*//from  w  w w  . ja v a2s  . c o  m
  $Id$
    
  Copyright (C) 2009-2010 Virginia Tech.
  All rights reserved.
    
  SEE LICENSE FOR MORE INFORMATION
    
  Author:  Middleware Services
  Email:   middleware@vt.edu
  Version: $Revision$
  Updated: $Date$
*/

import java.sql.Timestamp;
import java.util.Calendar;

public class Main {
    /**
     * Converts a {@link Calendar} into a SQL timestamp.
     *
     * @param  cal  Calendar to convert.
     *
     * @return  Equivalent timestamp.
     */
    public static Timestamp toTimestamp(final Calendar cal) {
        final Timestamp ts = new Timestamp(cal.getTimeInMillis());
        return ts;
    }
}

Related

  1. toTimestamp(Date date)
  2. toTimestamp(Date date)
  3. toTimestamp(Date date)
  4. toTimeStamp(Date date, String time)
  5. toTimestamp(DateTime dt)
  6. toTimestamp(final Instant instant)
  7. toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond)
  8. toTimestamp(final java.sql.Date date)
  9. toTimestamp(final String pValue)