Aditya_Pandey Ответов: 1

Эквивалент objectve c для Android


Я хочу преобразовать этот код objective c в эквивалент чистого android на java.

Это код "objective c" :


frDateStr=[NSString stringWithFormat:@"1505%d",theYear];
toDateStr=[NSString stringWithFormat:@"0109%d",theYear];


fromDate=[dFormatter dateFromString:frDateStr];
toDate=[dFormatter dateFromString:toDateStr];

fromInter=[fromDate timeIntervalSinceReferenceDate];
toInter=[toDate timeIntervalSinceReferenceDate];
currDateInter=[[NSDate date] timeIntervalSinceReferenceDate];

//Current date exists when :
//If currentdate interval is greater or equal to fromdate interval..
//or if currentdate interval is less or equal to todate interval
if([yearName isEqualToString:@"Senior"])
{
    if((int)currDateInter >= (int)fromInter && (int)currDateInter <= (int)(toInter))
    {

        if(![self.ignoredArray containsObject:@"Freshman Budget"] && [yearName isEqualToString:@"Senior"])
        {
            [self.currentRemindersArray addObject:@"Freshman Budget"];

        }
    }




}



Кто-нибудь может мне помочь, пожалуйста? Спасибо.

1 Ответов

Рейтинг:
8

Aditya_Pandey

Вот решение:для Android-эквивалента.

String startingFrom = "05-15-"+ currentYear;
			String endingDate = "09-10-"+ currentYear;
		
		 	SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
		    Date CurrentDate = new Date();
	    	
		    Date fromConvertedDate = new Date();
			Date toConvertedDate = new Date();
			try {
				fromConvertedDate = dateFormat.parse(startingFrom);
				toConvertedDate = dateFormat.parse(endingDate);
				//CurrentDate =dateFormat.parse(CurrentDatei);
				
			} catch (ParseException e) {
				e.printStackTrace();
			}
				 
		 	if (yearName.equalsIgnoreCase("Senior")) {

				if (CurrentDate.after(fromConvertedDate)
						&& CurrentDate.before(toConvertedDate)) {
					
            // Freshman Budget
	        Cursor cursorC = myDbHelper.retrieveAllReminders("Freshman Budget ");					
					
		    if (cursorC.moveToFirst()) {
						
							ReminderVO reminderVO = new ReminderVO();

 							String data = cursorC.getString(cursorC
									.getColumnIndex("Title"));
							String data1 = cursorC.getString(cursorC
									.getColumnIndex("Description"));
							reminderVO.setEntryDescription(data1);
							reminderVO.setEntryTitle(data);
							arr2ListItems.add(reminderVO);
						
							listView.setAdapter(new CustomListAdapter(this,
									arr2ListItems));				
					}
					cursorC.moveToFirst();
				}}