Java的国际话

时间日期的处理设计

 

<textarea cols="50" rows="15" name="code" class="c-sharp">/** * */ package com; import java.text.DateFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.Locale; /** * @author Administrator * */ public class Barn { public static void main(String[] args) { System.out.println(Calendar.getInstance()); System.out.println(Calendar.getInstance().getTime()); Date d = Calendar.getInstance().getTime(); System.out.println(d); DateFormat df = DateFormat.getDateInstance(); Date d2 = null; try { d2 = df.parse("2010-09-12"); } catch (ParseException e) { e.printStackTrace(); } System.out.println(d2); String fm = df.format(d); System.out.println(fm); DateFormat df2 = DateFormat.getDateInstance(DateFormat.FULL, new Locale("pt", "BR")); String fm2 = df2.format(d); System.out.println(fm2); float f = 123.4567F; NumberFormat nf = NumberFormat.getInstance(new Locale("fr")); NumberFormat nf2 = NumberFormat.getCurrencyInstance(); Locale l = new Locale("fr"); NumberFormat nf3 = NumberFormat.getCurrencyInstance(l); String str1 = nf.format(f); System.out.println(str1); System.out.println(nf2.format(f)); System.out.println(nf3.format(f)); } } </textarea>

 

 

java.util.GregorianCalendar[time=1284295557406,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2010,MONTH=8,WEEK_OF_YEAR=38,WEEK_OF_MONTH=3,DAY_OF_MONTH=12,DAY_OF_YEAR=255,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=45,SECOND=57,MILLISECOND=406,ZONE_OFFSET=28800000,DST_OFFSET=0]
Sun Sep 12 20:45:57 CST 2010
Sun Sep 12 20:45:57 CST 2010
Sun Sep 12 00:00:00 CST 2010
2010-9-12
Domingo, 12 de Setembro de 2010
123,457
¥123.46
123,46 ¤

你可能感兴趣的:(java,Date,String,sun,float,2010)