Simple example to show how to use Date Formatting in Java

Given that 1119280000000L is reoughly the number of milliseconds from Jan 1, 1970, to June 20, 2005, and that you want to print that date in German, using LONG style such that “June” will be displayed as “Juni”.

import java.text.*;
import java.util.*;
//import java.date.*;// There is such package defined in Java!!
public class DateFormatExample {
    public static void main(String[] args){
        Date d = new Date(1119280000000L);
        DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.GERMANY);
        System.out.println(df.format(d));
    }
}

Simple example of Java file/directory

import java.io.File;
public class Maker {
    public static void main(String[] args){
        try{
            File dir = new File("dir3");
            dir.mkdir();
            File file = new File(dir,"file3");
            file.createNewFile();
        }catch(Exception x){
 
        }
    }
}

Continue »

IdeaPad3

IdeaPad for this weekend.

Weekend is good.

1. I’m going to use NetBeans, Dojo, MySQL, PHP to make a online memo, so I will never need to write down what I want to do.

2. Color Picker which is useful for web developer.

3. What I got to implement, and put it online or make a package for download.

Fav3

The following are my favorate for this week:

1. Using NetBeans to do PHP. This is good because we can borrow J2EE’s design method and make very reasonable model based on real entity.

2. Using NetBeans to do JavaScript Library. The IDE combines some popular JS libraries, such as JQuery, Prototype, Dojo, YahooUI, etc. The best part is that the IDE can help pop up the available functions in the JavaScript Library, like java.

3. Dojo is a very nice JavaScript library, I haven’t play with it, but soon.

Such a nice CSS, simple but with everything

Here is a good css that is from Netbeans.org. When using JQuery’s plugin accordion, this css will produce a very nice accordion.

body { width: 40em; margin: auto; }
a { outline: none; }
 
.ui-accordion {
	 margin: 0; padding: 0;
	 }
.ui-accordion li {
	 list-style-type: none;
	 border-bottom: 2px solid white;
	 }
.ui-accordion li .ui-accordion-header {
	 margin: 0; padding: 0 1em;
	 font: bold 14px/28px sans-serif;
	 color: #eef;
	 background-color: #aaf;
	 text-decoration: none;
	 display: block;
	 }
 
a.personName:hover { color: white; }
ul.infolist { display: block; }
 
.person {
	 background-color: #eef;
	 margin: 0; padding: 0;
	 border-bottom: 1px solid #ccf;
	 }
.person ul { padding: 0 3em 2em; }
.person ul li {
	 padding-top: 1em;
	 border: 0 none;
	 }
 
li:before {
	 color: #66f;
	 font-weight: bold;
	 display: inline-block;
	 width: 4.5em;
	 }
 
li.portrait img {
	 float: right;
	 margin: 1em;
	 border: 1px solid #ccf;
	 }
li.title:before { content: "Title: "; }
li.office:before { content: "Office: "; }
li.phone:before { content: "Phone: "; }
li.email:before { content: "E-mail: "; }
li.bio:before { content: "Bio: "; }

Diagram to show java string’s immutability

A perfect diagram to explain java string’s immutability.

java_string_immutability

java_string_immutability

PHP Excel 2007 classes

In our PHP system, we need we translate some data in a table to an excel file.  I got several candidate, finally I decide to use PHPExcel, it is very easy to use and there is no need to install anything, just enable php_zip. You can download the package in this website.   In the downloaded package, there is a document and some sample PHP program.

Review of TurboTax

99 percent you should not use this software, if you are non resident alien, such as international students.
Several days ago, I tried TurboTax software. It is pretty cool. The users only need to answer very simple questions, and the software will generate the tax return automatically and produce the appropriate forms. However, one thing need to be careful. It is only good for US residant, international students need to use NR forms. The system doesn’t very clearly shows this, so be careful.