I need to write a method to get day of week (pacific time) for current time. Is the following code correct?
static Calendar s_calendar = Calendar.getInstance(Locale.US);
static {
    s_calendar.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
}
public static int getDayOfWeek() {
    s_calendar.setTimeInMillis(S开发者_开发知识库ystem.currentTimeMillis());
    return s_calendar.get(Calendar.DAY_OF_WEEK);
}
Thanks.
Use below:
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Los_Angeles"),
    Locale.US);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
System.currentTimeMillis() returns the millis in UTC. Convert it before you call get(Calendar.DAY_OF_WEEK)
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论