Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Regional formatting


Regional formatting is the manner in which various information, such as currency, date, and time is displayed according to the different regions of the world. In this recipe, we will discuss how to display formatted numbers and dates according to the user's regional formatting settings.

Getting ready

Create a new Single View Application in Xamarin Studio and name it RegionalFormattingApp.

How to do it...

Perform the following steps:

  1. Add five labels on the view of RegionalFormattingAppViewController.

  2. Enter the following code in the RegionalFormattingAppViewController class:

    public override void ViewDidAppear (bool animated)
    {
      base.ViewDidAppear (animated);
      this.lblLocale.Text = string.Format("Locale: {0}", NSLocale.CurrentLocale.LocaleIdentifier);
      this.lblDate.Text = string.Format("Date: {0}", DateTime.Now.ToLongDateString());
      this.lblTime.Text = string.Format("Time: {0}", DateTime.Now.ToLongTimeString());
      this.lblCurrency.Text = string.Format("Currency: {0:c}", 250...