當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.CANADA屬性代碼示例

本文整理匯總了Java中java.util.Locale.CANADA屬性的典型用法代碼示例。如果您正苦於以下問題:Java Locale.CANADA屬性的具體用法?Java Locale.CANADA怎麽用?Java Locale.CANADA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.Locale的用法示例。


在下文中一共展示了Locale.CANADA屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addToHabits

/**
 * Add Habit object to either fulfilledHabits or unfulfilledHabits. Consider the habit finished
 * within today as a recent completed habit.
 * @param habit Habit object.
 * @param today Today.
 */
private void addToHabits(Habit habit, Calendar today) {
    boolean notPast = false;
    boolean isToday = false;
    boolean shouldOccur = false;
    Calendar habitDate = habit.getHabitDate();
    // https://www.tutorialspoint.com/java/util/calendar_getdisplaynames.htm
    Locale locale = Locale.CANADA;
    String todayOfWeek = today.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MMM dd");

    if (today.after(habitDate)) {
        notPast = true;
    }
    if (dateFormat.format(today.getTime()).equals(habitDate)) {
        isToday = true;
    }
    if (habit.getOccurDays().contains(todayOfWeek)) {
        shouldOccur = true;
    }

    if ((notPast || isToday) && shouldOccur) {
        if (habit.getFulfilDate().isEmpty()) {
            unfulfilledHabits.add(habit);
        } else {
            for (Calendar date : habit.getFulfilDate()) {
                // if the habit has been fulfilled today
                if (dateFormat.format(date.getTime()).equals(dateFormat.format(today.getTime()))) {
                    fulfilledHabits.add(habit);
                    break;
                }
            }
        }
    }
}
 
開發者ID:TongTongX,項目名稱:HabitTracker,代碼行數:40,代碼來源:MainActivity.java

示例2: _getDataForPatterns

private Object[][] _getDataForPatterns()
{
  // pattern, inputvalue,locale,timezone
  Object[][] data =
  {
    {"yyyy.MM.dd G 'at' HH:mm:ss z", "2001.07.04 AD at 12:08:56 PDT", Locale.US, null },

    {"EEE, MMM d, ''yy","Wed, Jul 4, '01", Locale.ENGLISH, getTzone("GMT")},

    {"h:mm a","12:08 PM", Locale.GERMAN, getTzone("GMT+1")},

    {"hh 'o''clock' a, zzzz","12 o'clock PM, Pacific Standard Time", Locale.CANADA, getTzone("GMT-8")},

    {"K:mm a, z","0:08 PM, PST", Locale.US, getTzone("PST")},

    {"yyyyy.MMMMM.dd GGG hh:mm aaa","02001.July.04 AD 12:08 PM", Locale.US, null},
    {"EEE, d MMM yyyy HH:mm:ss Z","Wed, 4 Jul 2001 12:08:56 GMT",Locale.US, getTzone("GMT")},
    {"yyMMddHHmmss", "010704120856", Locale.ENGLISH, null, null},

  };
  return data;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:TrinidadDateTimeConverterTest.java

示例3: getView

/**
 * Values to deplay in list
 * @param position
 * @param convertView
 * @param parent
 * @return
 */
@Override
public View getView(int position, View convertView, ViewGroup parent){
    HabitEvent h = getItem(position);
    if (convertView==null){
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.habit_event_list_item, parent, false);
    }
    TextView date = (TextView) convertView.findViewById(R.id.eventDate);
    TextView comment = (TextView) convertView.findViewById(R.id.eventComment);
    TextView location = (TextView) convertView.findViewById(R.id.eventLocation);
    ImageView image = (ImageView) convertView.findViewById(R.id.eventPhoto);
    if (h.getEncodedPhoto()!=null && !h.getEncodedPhoto().isEmpty()){
        image.setImageBitmap(ImageController.base64ToImage(h.getEncodedPhoto()));
    }
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd", Locale.CANADA);
    date.setText(dateFormat.format(h.getDate()));
    if (h.getComment()==null){
        comment.setVisibility(View.INVISIBLE);
    }else{
        comment.setText(h.getComment());
    }
    if(h.getLat()!=null && h.getLong() != null){
        location.setText("("+ Location.convert(h.getLat(), Location.FORMAT_DEGREES)+","+Location.convert(h.getLong(), Location.FORMAT_DEGREES)+")");
    }else{
        location.setText("No Location Added");
    }

    return convertView;
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:35,代碼來源:HabitEventArrayAdapter.java

示例4: isSharedFlyweight

private static boolean isSharedFlyweight(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj == Boolean.TRUE || obj == Boolean.FALSE) {
        return true;
    }
    if (/* obj == Locale.ROOT || *//* Java 6 */
    obj == Locale.ENGLISH || obj == Locale.FRENCH || obj == Locale.GERMAN || obj == Locale.ITALIAN
            || obj == Locale.JAPANESE || obj == Locale.KOREAN || obj == Locale.CHINESE
            || obj == Locale.SIMPLIFIED_CHINESE || obj == Locale.TRADITIONAL_CHINESE || obj == Locale.FRANCE
            || obj == Locale.GERMANY || obj == Locale.ITALY || obj == Locale.JAPAN || obj == Locale.KOREA
            || obj == Locale.CHINA || obj == Locale.PRC || obj == Locale.TAIWAN || obj == Locale.UK
            || obj == Locale.US || obj == Locale.CANADA || obj == Locale.CANADA_FRENCH) {
        return true;
    }
    if (obj == Collections.EMPTY_SET || obj == Collections.EMPTY_LIST || obj == Collections.EMPTY_MAP) {
        return true;
    }
    if (obj == BigInteger.ZERO || obj == BigInteger.ONE) {
        return true;
    }
    if (obj == System.in || obj == System.out || obj == System.err) {
        return true;
    }
    if (obj == String.CASE_INSENSITIVE_ORDER) {
        return true;
    }
    if (obj == JarFile.MANIFEST_NAME) {
        return true;
    }
    return false;
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:33,代碼來源:ObjectProfiler.java

示例5: getView

/**
 * Get list view of habits
 * @param position
 * @param convertView
 * @param parent
 * @return
 */
@Override
public View getView(int position, View convertView, ViewGroup parent){
    Habit h = getItem(position);
    if (convertView==null){
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.habit_list_item, parent, false);
    }
    TextView title = (TextView) convertView.findViewById(R.id.habitTitle);
    TextView reason = (TextView) convertView.findViewById(R.id.habitReason);
    TextView startDate = (TextView) convertView.findViewById(R.id.habitStartDate);
    TextView textStats = (TextView) convertView.findViewById(R.id.habitStats);
    title.setText(h.getTitle());
    reason.setText(h.getReason());
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd", Locale.CANADA);
    startDate.setText(dateFormat.format(h.getStartDate()));
    ImageView imageView = (ImageView) convertView.findViewById(R.id.habitImage);
    float possibleEvents = h.getPossibleEvents();
    float stats = ((h.getEventsCompleted()/possibleEvents)*100);
    if (possibleEvents==0) stats=0;
    textStats.setText(String.format("%.0f",stats) + "%");
    if (stats<=statThreshold){
        textStats.setTextColor(Color.parseColor("#D12121"));
    }else{
        textStats.setTextColor(Color.parseColor("#41C61F"));
    }
    Calendar c = Calendar.getInstance();
    Calendar latest = getLatestHabitEventDate(h);
    if ((h.getSchedule()!=null && h.getSchedule().contains(c.get(Calendar.DAY_OF_WEEK))) && (h.getEvents()==null || !sameDay(c,latest))){
        //Set alarm icon if the habit is schedule for today and
        //if we either have no events, or the latest event wasn't today:
        imageView.setImageResource(R.drawable.ic_alarm);
    }else {
        //If over half of the possible events have been completed:
        if (stats>statThreshold) {
            imageView.setImageResource(R.drawable.ic_checkmark);
        } else {
            imageView.setImageResource(R.drawable.ic_offtrack);
        }
    }



    return convertView;
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:50,代碼來源:HabitArrayAdapter.java

示例6: getView

@Override
public View getView(int position, View convertView, ViewGroup parent){
    Habit h = getItem(position);
    if (convertView==null){
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.followed_habits_list_item, parent, false);
    }
    TextView owner = (TextView) convertView.findViewById(R.id.habitOwner);
    TextView title = (TextView) convertView.findViewById(R.id.habitTitle);
    TextView reason = (TextView) convertView.findViewById(R.id.habitReason);
    TextView startDate = (TextView) convertView.findViewById(R.id.habitStartDate);
    TextView textStats = (TextView) convertView.findViewById(R.id.habitStats);
    owner.setText(String.format("%s",h.getProfile())+"'s habit:");
    title.setText(h.getTitle());
    reason.setText(h.getReason());
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd", Locale.CANADA);
    startDate.setText(dateFormat.format(h.getStartDate()));
    ImageView imageView = (ImageView) convertView.findViewById(R.id.habitImage);
    float possibleEvents = h.getPossibleEvents();
    float stats = ((h.getEventsCompleted()/possibleEvents)*100);
    if (possibleEvents==0) stats=0;
    textStats.setText(String.format("%.0f",stats) + "%");
    if (stats<=statThreshold){
        textStats.setTextColor(Color.parseColor("#D12121"));
    }else{
        textStats.setTextColor(Color.parseColor("#41C61F"));
    }
    Calendar c = Calendar.getInstance();
    Calendar latest = getLatestHabitEventDate(h);
    if ((h.getSchedule()!=null && h.getSchedule().contains(c.get(Calendar.DAY_OF_WEEK)) && latest!=null) && (h.getEvents()==null || !sameDay(c,latest))){
        //Set alarm icon if the habit is schedule for today and
        //if we either have no events, or the latest event wasn't today:
        imageView.setImageResource(R.drawable.ic_alarm);
    }else {
        //If over half of the possible events have been completed:
        if (stats>statThreshold) {
            imageView.setImageResource(R.drawable.ic_checkmark);
        } else {
            imageView.setImageResource(R.drawable.ic_offtrack);
        }
    }



    return convertView;
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:45,代碼來源:FollowedHabitsArrayAdapter.java

示例7: testAppropriateFormatsArePicked

public void testAppropriateFormatsArePicked()
{
  // check if appropriate formtas based on the types are chosen.
  // like numeric, currency, percent are picked. Chose pattern if set avoiding
  // types

  String[] patterns = {"##,##",null, null, null,null};

  //pick pattern, numeric, percent, currency
  String[] types = {null,"number", "percent", "currency", "currency"};
  String[] inputValues = {"99,99","99", "99%","$99", "$99.00"} ;
  Number[] expectedValues = {new Long(9999), new Long(99), new Double(0.99), new Long(99), new Long(99)};
  String[] expectedStringValues = {"99,99","99", "99%","$99.00", "$99.00"} ;
  Locale usLocl = Locale.US;
  Locale[] locales = {usLocl, usLocl, usLocl, usLocl,Locale.CANADA};

  NumberConverter nconv = getNumberConverter();

  for (int i = 0; i < patterns.length; i++)
  {
    Mock mock = mock(UIComponent.class);
    UIComponent component = (UIComponent) mock.proxy();
    //we do not care about getValueExpression() being called or not
    mock.stubs().method("getValueExpression");


    setFacesContext(facesContext);
    try
    {
      nconv.setPattern(patterns[i]);
      nconv.setType(types[i]);
      nconv.setLocale(locales[i]);
      
      Object convValue = nconv.getAsObject(facesContext, component, inputValues[i]);
      
      // Trinidad does BigDecimal, for some reasons.
      // see TRINIDAD-1124
      if(i==2)
      {
        convValue = ((Number) convValue).doubleValue();
      }
      else
      {
        convValue = ((Number) convValue).longValue();
      }

      assertEquals(expectedValues[i], convValue);
      
      String outValue = nconv.getAsString(facesContext, component, expectedValues[i]);
      
      assertEquals(expectedStringValues[i], outValue);
    }
    finally
    {
      setFacesContext(null);
    }
    mock.verify();
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:59,代碼來源:NumberConverterTestCase.java


注:本文中的java.util.Locale.CANADA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。