Question: I'm attempting to describe running ec2 instances that I'm using with the following code:

```
DescribeInstancesResult describeInstancesRequest = ec2.describeInstances();
            List<Reservation> reservations = describeInstancesRequest.getReservations();
            Set<Instance> instances = new HashSet<Instance>();

            for (Reservation reservation : reservations) {
                instances.addAll(reservation.getInstances());
            }

            System.out.println("You have " + instances.size() + " Amazon EC2 instance(s) running.");

```

I'm getting a return result of 0. I'm guessing this is because the default AZ is set to US-East.

My instances are running in US-West.

How do I change the AZ?

Answer: 
Besides the above answers, you can easily create a little extension method to handle these cases gracefully:

```
public static class ExtensionUtils
{
    public static int ToZeroIfNotInt(this string valueToConvert)
    {
        int number =0;
        int.TryParse(valueToConvert,out number);
        return number;
    }
}

```

And then call it as so: 

```
renewalGracePeriodDays = row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text.ToZeroIfNotInt();

```
It's possible that the column you are checking is either an empty string, or contains non-integer data. I recommend using the TryParse method.

```
int renewalGracePeriodDays;
if (!int.TryParse(row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text), out renewalGracePeriodDays)
{
    renewalGracePeriodDays = 0;
    // Inside here, you can log the exception, alert the user, or end processing
}

```

If the TryParse fails, your grace period will default to 0. It's a good idea to use this method when dealing with user inputs, because there's no telling what people will enter, even when properly prompted...