Forum Xamarin.Forms

how to create singleton class.

i want to create singleton class for DateFormatter.
Which convert date according to my format and return in string.

Can anyone help me?

Answers

  • JohnHardmanJohnHardman GBUniversity admin

    @Neeraj_Kumar said:
    i want to create singleton class for DateFormatter.
    Which convert date according to my format and return in string.

    Can anyone help me?

    What have you tried? Which bit do you need help with?

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    Unclear what you really ask but maybe you just want to format a date as explained here: https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1

  • ColeXColeX Member, Xamarin Team Xamurai

    There is no need to use singleton class , ToString method can achieve this , copy from the link Xavier provided.

           DateTime aDate = DateTime.Now;  
    
            // Format Datetime in different formats and display them  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy"));  
            Console.WriteLine(aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"));  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy HH:mm"));  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy hh:mm tt"));  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy H:mm"));  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy h:mm tt"));  
            Console.WriteLine(aDate.ToString("MM/dd/yyyy HH:mm:ss"));  
            Console.WriteLine(aDate.ToString("MMMM dd"));  
            Console.WriteLine(aDate.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK"));  
            Console.WriteLine(aDate.ToString("ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT’"));  
            Console.WriteLine(aDate.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss"));  
            Console.WriteLine(aDate.ToString("HH:mm"));  
            Console.WriteLine(aDate.ToString("hh:mm tt"));  
            Console.WriteLine(aDate.ToString("H:mm"));  
            Console.WriteLine(aDate.ToString("h:mm tt"));  
            Console.WriteLine(aDate.ToString("HH:mm:ss"));  
            Console.WriteLine(aDate.ToString("yyyy MMMM"));  
    
Sign In or Register to comment.