Java‎ > ‎

timestamp


java no space timestamp

        Calendar cal = Calendar.getInstance();
        String timeStamp = "";
        timeStamp += String.valueOf(cal.get(Calendar.YEAR));
        timeStamp += String.valueOf(cal.get(Calendar.MONTH));
        timeStamp += String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
        timeStamp += String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
        timeStamp += String.valueOf(cal.get(Calendar.MINUTE));
        timeStamp += String.valueOf(cal.get(Calendar.SECOND));
        System.out.println(timeStamp);

Standard timestamp

        java.util.Date date= new java.util.Date();
        System.out.println(new java.sql.Timestamp(date.getTime()));





Comments