Java Code Examples for java.util.Locale.CANADA

The following are Jave code examples for showing how to use CANADA of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: myfaces-trinidad   File: TrinidadDateTimeConverterTest.java   View Source Code Vote up 6 votes
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;
}
 
Example 2
Project: HabitTracker   File: MainActivity.java   View Source Code Vote up 6 votes
/**
 * 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;
                }
            }
        }
    }
}
 
Example 3
Project: GoalsAndHabits   File: HabitEventArrayAdapter.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 4
Project: otter-G   File: ObjectProfiler.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: GoalsAndHabits   File: HabitArrayAdapter.java   View Source Code Vote up 4 votes
/**
 * 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;
}
 
Example 6
Project: GoalsAndHabits   File: FollowedHabitsArrayAdapter.java   View Source Code Vote up 4 votes
@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;
}
 
Example 7
Project: myfaces-trinidad   File: NumberConverterTestCase.java   View Source Code Vote up 4 votes
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();
  }
}