import java.util.Locale;
public class TestLocale {
public static void main(String[] args) {
Locale l1= Locale.CHINA;//根据国家可以确定语言。
Locale l2= Locale.CHINESE;//根据语言不能确定国家。
System.out.println(l1.getCountry());
System.out.println(l1.getLanguage());
System.out.println(l1.getDisplayCountry());
System.out.println(l1.getDisplayLanguage());
System.out.println("*************");
System.out.println(l2.getCountry());
System.out.println(l2.getLanguage());
System.out.println(l2.getDisplayCountry());
System.out.println(l2.getDisplayLanguage());
}
}
import java.util.Locale;
import java.text.NumberFormat;
public class TestNumberFormat {
public static void main(String[] args) {
Locale l1 = Locale.CHINA;//先得到国家。
Locale l2 = Locale.JAPAN;
Locale l3 = Locale.GERMAN;
double d =12345.67;
NumberFormat nf1 = NumberFormat.getInstance(l1);//再得到国家的数字格式。
NumberFormat nf2 = NumberFormat.getInstance(l2);
NumberFormat nf3 = NumberFormat.getInstance(l3);
System.out.println(nf1.format(d));
System.out.println(nf2.format(d));
System.out.println(nf3.format(d));
NumberFormat nf4 = NumberFormat.getCurrencyInstance(l1);//得到该国家的货币格式。
NumberFormat nf5 = NumberFormat.getCurrencyInstance(l2);
NumberFormat nf6 = NumberFormat.getCurrencyInstance(l3);
System.out.println(nf4.format(d));//再把数字按该国家格式进行格式化。
System.out.println(nf5.format(d));
System.out.println(nf6.format(d));
}
}
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.text.SimpleDateFormat;
public class TestSimpleDate {
public static void main(String[] args) {
Calendar c = new GregorianCalendar(2008,7,8,20,8,8);
Date d = c.getTime();
String p ="yyyy/MM/dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(p);
System.out.println(sdf.format(d));
String pp ="今天是yyyy年MM月";
SimpleDateFormat sdf1 = new SimpleDateFormat(pp);
System.out.println(sdf1.format(d));
}
}
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class TestDate {
public static void main(String[]args){
Calendar c = new GregorianCalendar(2008,7,8,20,8,8);
Date d = c.getTime();
java.sql.Date date = new java.sql.Date(d.getTime());
System.out.println(date);
System.out.println(d);
}
}
public class TestLocale {
public static void main(String[] args) {
Locale l1= Locale.CHINA;//根据国家可以确定语言。
Locale l2= Locale.CHINESE;//根据语言不能确定国家。
System.out.println(l1.getCountry());
System.out.println(l1.getLanguage());
System.out.println(l1.getDisplayCountry());
System.out.println(l1.getDisplayLanguage());
System.out.println("*************");
System.out.println(l2.getCountry());
System.out.println(l2.getLanguage());
System.out.println(l2.getDisplayCountry());
System.out.println(l2.getDisplayLanguage());
}
}
import java.util.Locale;
import java.text.NumberFormat;
public class TestNumberFormat {
public static void main(String[] args) {
Locale l1 = Locale.CHINA;//先得到国家。
Locale l2 = Locale.JAPAN;
Locale l3 = Locale.GERMAN;
double d =12345.67;
NumberFormat nf1 = NumberFormat.getInstance(l1);//再得到国家的数字格式。
NumberFormat nf2 = NumberFormat.getInstance(l2);
NumberFormat nf3 = NumberFormat.getInstance(l3);
System.out.println(nf1.format(d));
System.out.println(nf2.format(d));
System.out.println(nf3.format(d));
NumberFormat nf4 = NumberFormat.getCurrencyInstance(l1);//得到该国家的货币格式。
NumberFormat nf5 = NumberFormat.getCurrencyInstance(l2);
NumberFormat nf6 = NumberFormat.getCurrencyInstance(l3);
System.out.println(nf4.format(d));//再把数字按该国家格式进行格式化。
System.out.println(nf5.format(d));
System.out.println(nf6.format(d));
}
}
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.text.SimpleDateFormat;
public class TestSimpleDate {
public static void main(String[] args) {
Calendar c = new GregorianCalendar(2008,7,8,20,8,8);
Date d = c.getTime();
String p ="yyyy/MM/dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(p);
System.out.println(sdf.format(d));
String pp ="今天是yyyy年MM月";
SimpleDateFormat sdf1 = new SimpleDateFormat(pp);
System.out.println(sdf1.format(d));
}
}
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class TestDate {
public static void main(String[]args){
Calendar c = new GregorianCalendar(2008,7,8,20,8,8);
Date d = c.getTime();
java.sql.Date date = new java.sql.Date(d.getTime());
System.out.println(date);
System.out.println(d);
}
}