006: Finding Java System Properties

// File: io/properties/SysPropList.java
// Description: Shows system properties.  This must be an application.
//              An applet can't get this information.
// Author: Fred Swartz
// Date:   2 Feb 2005

import java.awt.*;
import javax.swing.*;
import java.util.*;

/** Generic main program. */
public class SysPropList {
    public static void main(String[] args) {
        JFrame window = new JFrame("System Properties");
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setContentPane(new SysPropListGUI());
        window.pack();
        window.setVisible(true);
    }
}

/** Panel to display the (limited) GUI intereface. */
class SysPropListGUI extends JPanel {
    JTextArea m_propertiesTA = new JTextArea(20, 40);

    /** Constructor sets layout, adds component(s), sets values*/
    public SysPropListGUI() {
        this.setLayout(new BorderLayout());
        this.add(new JScrollPane(m_propertiesTA), BorderLayout.CENTER);

        //... Add property list data to text area.
        Properties pr = System.getProperties();

	// TreeSet sorts keys
        TreeSet propKeys = new TreeSet(pr.keySet());  
        for (Iterator it = propKeys.iterator(); it.hasNext(); ) {
            String key = (String)it.next();
            m_propertiesTA.append("" + key + "=" + pr.get(key) + "n");
        }
    }
}

Java System Properties Snapshot

Originally posted 2008-05-12 08:17:55.

Share

007: Date From Timestamp in Long format

Generally, the dates are stored in long timestamp format in the database.
This simple class can convert the timestamp date to real date format.

-----------------------------------------------------------------------
package com.kushal.util;
import java.util.Date;
public class DateFromLong {

	public static void main(String ags [])
	{
		long dateInLongFormat=1212499200000L;
		Date date=new Date(dateInLongFormat);

		System.out.println(date);

	}

}
------------------------------------------------------------------------
Here is the sample output for the long date give above:

Tue Jun 03 08:20:00 CDT 2008

Blog Widget by LinkWithin

Originally posted 2008-06-04 11:41:06.

Share