w3resource logo


C# Sharp Programming Exercises

C# Sharp Exercises: Display short date format for the ja-JP culture

Secondary Nav

C# Sharp DateTime : Exercise-26 with Solution

Write a C# Sharp program to  display the string representations of a date using the short date format specified for the ja-JP culture.

Expected Output :

2016/05/12                                                                       
16/05/12                                                                         
16/5/12                                                                          
2016/5/12                                                                        
16/05/12 (木)                                                                     
16/5/12 (木)                                                                      
2016/05/12 (木)                                                                   
2016-05-12                                                                       
2016年5月12日        
.....
2016年05月11日 水曜日 23:53:15                                                
2016年05月11日 水曜日 午後 11:53:15                                             
2016年05月11日 水曜日 午後 11:53:15

C# Sharp Code:

using System;
public class Example26
{
  public static void Main(String[] argv){  
    DateTime may12 = new DateTime(2016, 5, 12, 5, 23, 15, 16);

IFormatProvider culture = 
	new System.Globalization.CultureInfo("ja-JP", true);
// Get the short date formats using the "ja-JP" culture.
string [] frenchmay12Formats = 
			may12.GetDateTimeFormats(culture);

// Display may12 in various formats using "ja-JP" culture.
foreach (string format in frenchmay12Formats) {
	Console.WriteLine(format);
}
  }
}

C# Sharp Practice online:

using System;
public class Example26
{
  public static void Main(String[] argv){  
    DateTime may12 = new DateTime(2016, 5, 12, 5, 23, 15, 16);

IFormatProvider culture = 
	new System.Globalization.CultureInfo("ja-JP", true);
// Get the short date formats using the "ja-JP" culture.
string [] frenchmay12Formats = 
			may12.GetDateTimeFormats(culture);

// Display may12 in various formats using "ja-JP" culture.
foreach (string format in frenchmay12Formats) {
	Console.WriteLine(format);
}
  }
}

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program