| 1 |
package chinese.date.test; |
|---|
| 2 |
|
|---|
| 3 |
import java.util.Date; |
|---|
| 4 |
|
|---|
| 5 |
import com.ibm.icu.text.DateFormat; |
|---|
| 6 |
|
|---|
| 7 |
public class ChineseDateTest { |
|---|
| 8 |
|
|---|
| 9 |
public static void main(String[] args) { |
|---|
| 10 |
System.out.println("MEDIUM format: " + getTime(DateFormat.MEDIUM)); |
|---|
| 11 |
System.out.println("LONG format: " + getTime(DateFormat.LONG)); |
|---|
| 12 |
System.out.println("FULL format: " + getTime(DateFormat.FULL)); |
|---|
| 13 |
System.out.println("Done!"); |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
public static String getTime(int format){ |
|---|
| 17 |
try{ |
|---|
| 18 |
return DateFormat.getDateTimeInstance(format, format).format(new Date(System.currentTimeMillis())); |
|---|
| 19 |
} |
|---|
| 20 |
catch (RuntimeException e) |
|---|
| 21 |
{ |
|---|
| 22 |
e.printStackTrace(); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
return ""; |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|