Package java.sql

Examples of java.sql.Date


            target.set(Calendar.HOUR_OF_DAY, 0);
            target.set(Calendar.MINUTE, 0);
            target.set(Calendar.SECOND, 0);
            target.set(Calendar.MILLISECOND, 0);
        }
        Date result = new Date(target.getTimeInMillis());
        return result;
    }
View Full Code Here


                     "America/New_York"); //$NON-NLS-1$
    }

    public void testCreateDate() {
        Timestamp t = Timestamp.valueOf("2004-06-30 23:39:10.1201"); //$NON-NLS-1$
        Date date = TimestampWithTimezone.createDate(t);
       
        Calendar cal = Calendar.getInstance();
       
        cal.setTimeInMillis(date.getTime());
       
        assertEquals(cal.get(Calendar.HOUR_OF_DAY), 0);
        assertEquals(cal.get(Calendar.MINUTE), 0);
        assertEquals(cal.get(Calendar.SECOND), 0);
        assertEquals(cal.get(Calendar.MILLISECOND), 0);
View Full Code Here

   
    /**
     * Even though the id of the timezones are different, this should not change the result
     */
    public void testDateToDateConversion() {
      Date t = Date.valueOf("2004-06-30"); //$NON-NLS-1$
      Date converted = TimestampWithTimezone.createDate(t, TimeZone.getTimeZone("America/Chicago"), Calendar.getInstance(TimeZone.getTimeZone("US/Central"))); //$NON-NLS-1$ //$NON-NLS-2$
     
      assertEquals(t.getTime(), converted.getTime());
    }
View Full Code Here

     
      assertEquals(t.getTime(), converted.getTime());
    }
   
    public void testDateToDateConversion1() {
      Date t = Date.valueOf("2004-06-30"); //$NON-NLS-1$
      Date converted = TimestampWithTimezone.createDate(t, TimeZone.getTimeZone("America/Chicago"), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); //$NON-NLS-1$ //$NON-NLS-2$
     
      Calendar cal = Calendar.getInstance();
      cal.setTime(converted);
     
      assertEquals(0, cal.get(Calendar.MILLISECOND));
View Full Code Here

      orderForm.set("entityName", cvOrderForm.getCustomerName());
      orderForm.set("billingAddress", cvOrderForm.getBillToAdd());
      orderForm.set("shippingAddress", cvOrderForm.getShipToAdd());
      orderForm.set("status", cvOrderForm.getStatus());

      Date orderDate = (Date)cvOrderForm.getOrderDate();
      String formattedDate = "";
      orderForm.set("date", formattedDate);

      orderForm.set("terms", cvOrderForm.getTerms());
      orderForm.set("accountManager", cvOrderForm.getAcctMgr());
View Full Code Here

      invoiceForm.set("entityName", invoiceVO.getCustomerName());
      invoiceForm.set("billingAddress", invoiceVO.getBillToAddress());
      invoiceForm.set("shippingAddress", invoiceVO.getShipToAddress());
      invoiceForm.set("status", invoiceVO.getStatusName());

      Date invoiceDate = (Date)invoiceVO.getInvoiceDate();
      SimpleDateFormat dateFormatter = new SimpleDateFormat("MMMMM dd, yyyy");
      String formattedDate = dateFormatter.format(invoiceDate);
      invoiceForm.set("date", formattedDate);

      int termID = invoiceVO.getTermId();
View Full Code Here

        rs.addColumn("g", Types.VARCHAR, 0, 0);
        rs.addColumn("h", Types.ARRAY, 0, 0);
        rs.addColumn("i", Types.TIME, 0, 0);
        rs.addColumn("j", Types.TIMESTAMP, 0, 0);

        Date d = Date.valueOf("2001-02-03");
        byte[] b = {(byte) 0xab};
        Object[] a = {1, 2};
        Time t = Time.valueOf("10:20:30");
        Timestamp ts = Timestamp.valueOf("2002-03-04 10:20:30");
        rs.addRow(1, b, true, d, "10.3", Math.PI, "-3", a, t, ts);

        rs.next();

        assertEquals(1, rs.getLong(1));
        assertEquals((byte) 1, rs.getByte(1));
        assertEquals((short) 1, rs.getShort(1));
        assertEquals(1, rs.getLong("a"));
        assertEquals((byte) 1, rs.getByte("a"));
        assertEquals(1, rs.getInt("a"));
        assertEquals((short) 1, rs.getShort("a"));
        assertTrue(rs.getObject(1).getClass() == Integer.class);
        assertTrue(rs.getObject("a").getClass() == Integer.class);

        assertEquals(b, rs.getBytes(2));
        assertEquals(b, rs.getBytes("b"));

        assertTrue(rs.getBoolean(3));
        assertTrue(rs.getBoolean("c"));
        assertEquals(d.getTime(), rs.getDate(4).getTime());
        assertEquals(d.getTime(), rs.getDate("d").getTime());

        assertTrue(new BigDecimal("10.3").equals(rs.getBigDecimal(5)));
        assertTrue(new BigDecimal("10.3").equals(rs.getBigDecimal("e")));
        assertEquals(10.3, rs.getDouble(5));
        assertEquals((float) 10.3, rs.getFloat(5));
View Full Code Here

                testValue(ValueDecimal.get(new BigDecimal(i).setScale(j)));
                testValue(ValueDecimal.get(new BigDecimal(i * i).setScale(j)));
            }
            testValue(ValueDecimal.get(new BigDecimal(i * i)));
        }
        testValue(ValueDate.get(new Date(System.currentTimeMillis())));
        testValue(ValueDate.get(new Date(0)));
        testValue(ValueTime.get(new Time(System.currentTimeMillis())));
        testValue(ValueTime.get(new Time(0)));
        testValue(ValueTimestamp.get(new Timestamp(System.currentTimeMillis())));
        testValue(ValueTimestamp.get(new Timestamp(0)));
        testValue(ValueJavaObject.getNoCopy(new byte[0]));
View Full Code Here

        }
       
        // Get timestamp literal and break into pieces
        Timestamp ts = (Timestamp) timestampConstant.getValue();
        String tsStr = ts.toString();
        Date date = Date.valueOf(tsStr.substring(0, 10));
        Time time = Time.valueOf(tsStr.substring(11, 19));
       
        // Get timestampCreate args
        Expression[] args = tsCreateFunction.getArgs();
       
View Full Code Here

            Object[] data = { new BigDecimal("" + i), //$NON-NLS-1$
                              new BigInteger(Integer.toString(i)),
                              (i%2 == 0) ? Boolean.FALSE: Boolean.TRUE,
                              new Byte((byte)i),
                              new Character((char)i),
                              new Date(currentTime),
                              new Double(i),
                              new Float(i),
                              new Integer(i),
                              new Long(i),
                              new Short((short)i),
View Full Code Here

TOP

Related Classes of java.sql.Date

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.