当前位置: 首页>>代码示例>>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;未经允许,请勿转载。