August 22, 2007

Convert a java.util.Date Object to a java.sql.Date Object

The following code demonstrates how to convert a java.util.Date object to a java.sql.Date object: import java.sql.*;import java.util.*;public class cs{public static void main(String[] args) { GregorianCalendar date_1=(GregorianCalendar)Calendar.getInstance(); System.out.println(date_1.getTime()); java.sql.Date date_2= new java.sql.Date((date_1.getTime()).getTime ()); System.out.println(date_2); }}

The Sizeof() Operator Only Works at Compile Time

The Sizeof () operator only works at compile time and doesn’t evaluate anything at run time. In the following code snippet, the func() function is never called. The inner sizeof() returns the size of short (return type of func()) and the outer sizeof() returns the size of size_t?in other words,

Using the SecureString Class

NET 2.0’s System.Security namespace includes the SecureString class, which lets you create encrypted strings and delete them from memory when they’re no longer needed. You can even make a string behave as a read-only string?and prevent any copies from being made, ensuring that there’s only a single copy in memory.

Infrared Programming Using the .NET Compact Framework

nfrared communication is one of the most common forms of communication for devices today. If you’ve ever used a TV remote control, you’ve experienced the convenience of using infrared communications. While infrared communications require line-of-sight between the sending and receiving devices, they are a quick and cheap way of communicating