CNET中国旗舰网站

ZDNet China | CNET科技资讯网 | 政府采购 | 行业网站联盟





 
标题: [原创] SCJP考试试题解析十一
mesum
超级会员
Rank: 4



UID 321006
精华 0
积分 1811
帖子 73
威望 722
ZD币 160 元
阅读权限 90
注册 2008-4-21
状态 离线
  楼主
发表于 2008-6-10 22:23  资料  个人空间  短消息  加为好友 
开发者在线

SCJP考试试题解析十一

SCJP考试试题解析十一


我的QQ号:2535279


www.javaedu.com.cn


Given the exhibit:

d is valid ,non-null Date object
df is valid ,non-null DateFormat object set to the current local

What outputs the current:local's country name and the appropriate version of d's date?

A.  Locale loc = Locale.getLocal();
        System.out.println(loc.getDisplayCountry());
        
B.  Locale loc = Locale.getDefault();
        System.out.println(loc.getDisplayCountry()+""+ df.format(d));
        
C.  Locale loc = Locale.getLocal();
        System.out.println(loc.getDisplayCountry()+""+df.setDateFormat(d));
        
D.  Locale loc = Locale.getDefault();
    System.out.println(loc.getDisplayCountry()+""+df.setDateFormat(d));        
   
    这个程序让我们完成的功能就是得到当前国家的名字,然后显示根据当地习惯显示的日期.
   
    我使用Locale类中提供的getDefault()方法获得此 Java 虚拟机实例的当前默认语言环境值。使用它的getDisplayCountry() 返回适合向用户显示的语言环境国家/地区名。
   
    DateFormat对象df的format()方法,将一个 Date 格式化为日期/时间字符串。这样就可以达到我们的要求了
   
    所以,答案为B.
   
    关于时间格式化问题,请参见帖子SCJP考试试题解析四




顶部
 



当前时区 GMT+8, 现在时间是 2009-7-4 11:27

  Powered by Discuz! 5.5.0 © 2001-2007 Comsenz Inc.
Processed in 0.059994 second(s), 4/3 queries

清除 Cookies - 联系我们 - ZDNetChina中文社区 - 无图版