Jin.ChineseDateFormatter
1.0.0
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Jin.ChineseDateFormatter --version 1.0.0
NuGet\Install-Package Jin.ChineseDateFormatter -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jin.ChineseDateFormatter" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jin.ChineseDateFormatter" Version="1.0.0" />
<PackageReference Include="Jin.ChineseDateFormatter" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jin.ChineseDateFormatter --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jin.ChineseDateFormatter, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jin.ChineseDateFormatter@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jin.ChineseDateFormatter&version=1.0.0
#tool nuget:?package=Jin.ChineseDateFormatter&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
说明
这是一个用于格式化中文日期的库。目前支持格式化年、月、日、星期四个部分并同时支持DateTime和DateOnly两种结构。
约定
- 支持的格式说明符:y(年)、M(月)、d(日)、w(星期);
- 由于中文年月日没有在前方补0的习惯,所以不同于.Net原本的用法,
y、M、d三种符号不区分数量多寡,即yyyy-MM-dd与y-M-d等同; w有两种形式,单个w显示为周,多个w显示为星期;- 默认格式为
y年M月d日,如2025-06-23格式化后为二〇二五年六月二十三日; - 除上述四种说明符外,其它字符均原样保留。
基本用法
using ChineseDateFormatter;
var dateTime = new DateTime(2025, 10, 12);
var dateOnly = new DateTime(2025, 10, 12);
//使用默认格式:y年M月d日
//输出:二〇二五年十月十二日
Console.WriteLine(dateTime.ToChineseString());
Console.WriteLine(dateOnly.ToChineseString());
//如果之前采用如 yyyy年MM月dd日 的格式化字符串,可以直接作为参数传入,结果与 y年M月d日 相同
//输出:二〇二五年十月十二日
Console.WriteLine(dateTime.ToChineseString("yyyy年MM月dd日"));
Console.WriteLine(dateOnly.ToChineseString("yyyy年MM月dd日"));
//仅保留年份
//输出:二〇二五年度
Console.WriteLine(dateTime.ToChineseString("y年度"));
Console.WriteLine(dateOnly.ToChineseString("y年度"));
//保留年和月
//输出:二〇二五年十月
Console.WriteLine(dateTime.ToChineseString("y年M月"));
Console.WriteLine(dateOnly.ToChineseString("y年M月"));
//显示星期
//输出:二〇二五年十月十二日星期日
Console.WriteLine(dateTime.ToChineseString("y年M月d日ww"));
Console.WriteLine(dateOnly.ToChineseString("y年M月d日ww"));
//输出:二〇二五年十月十二日周日
Console.WriteLine(dateTime.ToChineseString("y年M月d日w"));
Console.WriteLine(dateOnly.ToChineseString("y年M月d日w"));
//如果需要采用星期天而非星期日,可以传入选项 UseCasualSunday = true
//输出:二〇二五年十月十二日星期天
Console.WriteLine(dateTime.ToChineseString("y年M月d日ww", new FormatterOptions { UseCasualSunday = true }));
Console.WriteLine(dateOnly.ToChineseString("y年M月d日ww", new FormatterOptions { UseCasualSunday = true }));
//如果年份中需要采用零而非〇,可以传入选项 UseUpperCaseZero = true
//输出:二零二五年
Console.WriteLine(dateTime.ToChineseString("y年", new FormatterOptions { UseUpperCaseZero = true }));
Console.WriteLine(dateOnly.ToChineseString("y年", new FormatterOptions { UseUpperCaseZero = true }));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|