用C#实现将大写日期(年/月/日)转化为小写日期(阿拉伯数字的)

C# 时间格式转换为数字的方法 在 C# 中,我们经常需要将时间格式转化为数字,例如将日期表示为纯数字形式。本文将介绍如何使用 C# 将时间格式转换为数字,并提供相应的源代码和描述。假设我们要将当前日期转换为纯数字形式,即将年、月、日表示为一个整数。然后,通过将年乘以 10000,月乘以 100,日保持不变,并将它们相加,得到了纯数字形式的日期。以上是 C# 将时间格式转换为数字的方法及相应的源代码和描述。运行上述代码,将会以纯数字形式输出当前日期,例如 20230813。如果你想要将特定日期转换为纯数字形式,你可以使用类似的方法。 阅读详情

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 日期转换
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入大写日期");
            string inputCdate = Console.ReadLine();
            Console.WriteLine(DateConvert(inputCdate));
            Console.ReadKey();
        }
        private static string DateConvert(string date)
        {
            Dictionary<char, char> dict = new Dictionary<char, char>();
            string dictionary = "零0 一1 二2 三3 四4 五5 六6 七7 八8 九9";
            string[] parts = dictionary.Split(' ');
            for (int i = 0; i < parts.Length; i++)
            {
                dict.Add(parts[i][0], parts[i][1]);
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < date.Length; i++)
            {
                if (dict.ContainsKey(date[i]))
                {

                    sb.Append(dict[date[i]]);

                }
                else if (!dict.ContainsKey(date[i]) && date[i] != '十')
                {
                    sb.Append('-');
                }
                else
                {
                    if (!dict.ContainsKey(date[i - 1]) && !dict.ContainsKey(date[i + 1]))
                    {
                        sb.Append("10");
                    }
                    else if (!dict.ContainsKey(date[i - 1]) && dict.ContainsKey(date[i + 1]))
                    {
                        sb.Append("1");
                    }
                    else if (dict.ContainsKey(date[i - 1]) && !dict.ContainsKey(date[i + 1]))
                    {
                        sb.Append("0");
                    }

                    else if (dict.ContainsKey(date[i - 1]) && dict.ContainsKey(date[i + 1]))
                    {

                    }
                }
            }
            return (sb.ToString().TrimEnd('-'));

 

        }
    }
}


 

C#数字日期装换为中文日期(源码) C#数字日期装换为中文日期,源码1037 立即下载

相关推荐

C# 计算两个日期的时间间隔,精确到(年/月/日)

C# 计算两个日期的时间间隔,精确到(年/月/日)

c#把日期改成数字字符串_C#编写壹个函数将输入的中文日期转换为阿拉伯数字日期...

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DateConversion{class Program{static void Main(string[] args){//案例:编写一个函数进行日期转换,将输入的中文日期转换为阿拉伯数字日期,比如:二零一二年十二...

weixin_39784195的博客 1178

halcon 检测直线

图中后三个对象既是检测出的图像;

qq_59062726的博客 672

C# 字符串转化为时间格式

[csharp] view plaincopyprint? DateTimePicker dtp = new DateTimePicker();   string time = dataGridView_EquipDetailInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();  //上句得到的字符串格式是2010/

newnazi的专栏 1249

手把手拆解DGX GB200 NVL72:1个机柜如何塞进72块GPU?详解NVLink Switch铜缆背板设计

本文深度解析英伟达DGX GB200 NVL72系统如何通过NVLink Switch铜缆背板设计,在标准42U机柜中集成72块B200 GPU,实现1800GB/s的超高带宽。文章详细介绍了模块化架构、铜缆互连技术、液冷散热方案和高密度供电系统等核心创新,为AI算力需求提供突破性解决方案。

red88的博客 1636

AI视频生成提示词工程:结构化公式与实战案例详解

在实际使用 AI 生成视频或图像时,最常遇到的困惑是:为什么我的提示词(Prompt)生成的画面总是不理想?是模型能力不足,还是我的描述有问题?答案往往是后者。提示词工程(Prompt Engineering)并非简单的“翻译”需求,而是一门需要结构化思维和精准描述的技能。它决定了 AI 能否准确理解你的意图,并生成符合预期的视觉内容。 本文将通过两个核心案例,深入拆解提示词的构建逻辑。第一个案例聚焦于“文生视频”,我们将学习如何将一个简单的想法,如“小猫在雪地里玩雪球”,通过结构化公式扩展为一段富有细节和

weixin_30800987的博客 573

“yyyy-MM-dd”格式日期——分开得到年月日

“yyyy-MM-dd”格式日期——分开得到年月日

weixin_67340539的博客 818

OCR开发车架号识别vin码识别系统

一、vin码识别车架号识别系统简介   vin码识别车架号识别系统,结合VIN码主机厂数据库及自身多年文字识别经验,针对机动车配置参数等信息的查询及采集业务推出的一款VIN码自动识别产品。   车架号识别vin码识别,主要应用在智能手机IOS与Android两个平台中。前端扫描查询模式,无需联网,只需扫描汽车前挡风玻璃右下角的VIN玛(车架号),即可轻松识别出车辆产地、品牌、车

OCR13512721355的博客 1440

C#将日期转换中文格式显示

C# 将日期转换成中文格式 没有什么难点,只是要小心,要考虑到月、日上 10 的说法,比如:10 不能直接转换成一〇,也不能像上 20 那样转换成一十〇,应该是...

MrLsss的博客 2047

VisionMaster SDK C#二次开发核心技术指南

以下是基于**VisionMaster SDK C#二次开发核心技术指南**,结合实战案例与关键代码解析,帮助开发者快速掌握工业视觉应用集成。

东城十三 3094

自定义css属性实现渐变边框动画

自定义cs属性实现渐变边框动画

lemon的博客 1880

c#版的阿拉伯数字转中文大写,以及票据日期的写法

前接上篇,阿拉伯数字转中文数字是蛮有意思的,最近又有新发现~现在更新一下以前的代码~ c#版的阿拉伯数字转中文大写,以及票据日期的写法 不废话,直接上代码,两个方法 阿拉伯数字转中文: private static char[] CN_UPPER_NUM = { '零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖' }; pri

qqtt789632147的专栏 1025

【PostgreSQL教程】PostgreSQL 特别篇之 语言接口Java

本篇教程的Java程序中开始使用PostgreSQL之前,需要确保在计算机上设置了PostgreSQL JDBC和Java。您可以检查Java教程以在计算机上安装Java。现在让本篇教程检查如何设置PostgreSQL JDBC驱动程序。

No8g攻城狮的博客 1797

将大写数字的日期转换为阿拉伯数字的方法

    前两天在公司举行的编程比赛,做了一道题。如下:         编写一个函数进行日期转换,将输入的中文日期转换为阿拉伯数字日期,比如:二零零八年五月八日要转换为2008-05-08。    因为觉得有趣,而且有共通的地方。比如说将大写的现金金额转换成阿拉伯数字。故特扔出来抛砖引玉。        我用的是C#.                  private string

Jack_He的专栏 2260

勇闯dify v1.0.0之设置模型供应商。解决:Reached maximum retries (3) for URL https://marketplace.dify.ai/

朋友们,大家好,今天带大家来勇闯dify v1.0.0。为什么叫勇闯呢?我就这么说吧,本来我昨天就想带大家勇闯v1.0.0的。但是dify的marketplace访问不了。公司的网和手机热点都试了,就是访问不了。我们连个模型都没有,还勇闯个球啊,对吧,就搁置了。今天,我赶紧看看这个marketplace好了没。一看,可以了。赶紧写下这篇博客,帮助同志们走出困境。

xiezhipu的博客 4622

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

将大写日期转成阿拉伯数字类型的

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespac

gongth_12的专栏 1252

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

java 阿拉伯数字日期转换为中文大写日期方法_日期转换为中文大写数字

/// ///将日期转换为中文大写///如:一九八三 十一 二十七/// public classChineseNumberHelper{static Dictionary _theNumOfChineseCapital = new Dictionary(){{0,"〇"},{1,"一"},{2,"二"},{3,"三"},{4,"四"},{5,"五"},{6,"六"},{7,"七"},{8,"八"...

weixin_42512012的博客 942

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C#中把货币、日期转换成中文大写

View Code 1 public class UpperConvert 2 { 3 public UpperConvert() 4 { 5 // 6 // TODO: 在此处添加构造函数逻辑 7 // 8 } 9 //把数字转换为大写 10 public str...

a7257825001的博客 128

编写函数进行日期转换;键输入的大写的日期转换成阿拉伯数字的形式

用winfrom实现的!!!! Dictionary doct = new Dictionary();        private void button1_Click(object sender, EventArgs e)         {             StringBuilder str = new StringBuilder();             stri

shang_111111的专栏 929

日期转换

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _04日期转换a {     class Program     {         //编写函数进行日期转换;键输入的大写的日期转换成阿拉伯数字的形式。     //二零一二年三月十三日

xiaokang875797522的专栏 434

编写函数进行日期转换;键输入的大写的日期转换成阿拉伯数字的形式。

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 日期转换a { class Program { // 编写函数进行日期转换;将输入的大写的日期转换成阿拉伯数字的形式 //二零一二年三月十三日 1012-3-13 //二零一二年三月十日 ...

数据库天地 195

0725-字符串练习:汉字时间转为阿拉伯数字时间

这几天的.NET的基础加强,

ZQR程序人生 1022

C# 字典(dictionary)练习,日期翻译

编写一个函数进行日期转换,将输入的中文日期转换为阿拉伯数字日期,比如:二零一二年十二月二十一日要转换为2012-12-21。(处理“十”的问题:1.*月十日;2.*月十三日;3.*月二十三日;4.*月三十日;)4中情况对“十”的不同翻译。1→10;2→1;3→不翻译;4→0【年部分不可能出现’十’,都出现在了月与日部分。】   using System; using System.Colle

houyanhua1的专栏 807

.编写函数进行日期转换

.编写函数进行日期转换;键输入的大写的日期转换成阿拉伯数字的形式。 二零一二年三月十三日     2012-3-13 二零一二年三月十日       2012-3-10 二零一二年三月二十三日   2012-3-23 using System; using System.Collections.Generic; using System.Linq; using System.Text

gengyudan的专栏 703

日期转换 例如 二零零六年十二月二十一日 转换成 2006年12月21日

日期转换  例如 二零零六年十二月二十一日 转换成 2006年12月21日 class Program { static void Main(string[] args) { //编写一个函数进行日期转换,将输入的中文日期转换为阿拉伯数字日期,比如:二零一二年十二月二十一日要转换为2012-12-21.(处理“十”的问题:1,*...

nsjlive的博客 1603
上一篇: 声明一个哺乳动物类Mammal,再由此派生出狗类Dog,二者都定义Speak()成员函数,基类中定义为虚函数,声明类Dog的一个对象,调用函数Speak()
下一篇: C#基本语法-实现在控制台输出矩形的长宽面积
尤越
博客等级 码龄15年 13粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值