Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.44/5 (4 votes)
See more:
I want to convert this objective c code to equivalent to pure android in java.

This is " objective c " code:


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"];

        }
    }




}



Can anyone help me please? Thank you.
Posted
Updated 26-Aug-12 22:42pm
v4

1 solution

Here is the solution:For Android equivalent.
C#
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();
				}}
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900