惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
W
WeLiveSecurity
C
Check Point Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
A
Arctic Wolf
NISL@THU
NISL@THU
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
M
MIT News - Artificial intelligence
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tenable Blog
G
GRAHAM CLULEY
O
OpenAI News
S
Schneier on Security
Google Online Security Blog
Google Online Security Blog
Vercel News
Vercel News
宝玉的分享
宝玉的分享
Attack and Defense Labs
Attack and Defense Labs
T
The Blog of Author Tim Ferriss
量子位
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
P
Privacy & Cybersecurity Law Blog
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 热门话题
博客园_首页
F
Full Disclosure
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Docker
U
Unit 42
A
About on SuperTechFans
博客园 - 司徒正美
Hacker News - Newest:
Hacker News - Newest: "LLM"
人人都是产品经理
人人都是产品经理
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Scott Helme
Scott Helme
TaoSecurity Blog
TaoSecurity Blog

博客园 - weipt

终于!我造了个「AI代驾」级别的AutoBuilder,一键干掉80%的重复CRUD工作 OpenClaw 配置飞书机器人完整指南:从零到每天定时推送天气 国产数据库私有化部署实战:PolarDB for PostgreSQL 免费容器版踩坑记 发票打印还在花钱?这款免费小工具,A4纸一半大小、自动排版,真香! 🔥 自己写的FBX转3D Tiles工具,免费!还能当模型浏览器用 相同代码在360浏览器能显示,在edge提示webgl不支持,edge下都最新的内核。 什么是技术架构、数据架构、业务架构、应用架构和代码架构? 使用pyinstaller打包的exe文件太大,怎么办 2026无人机新规正式施行!各位飞手赶紧收藏 谈谈EF的两种模式 谈谈EF Core 微软官方的 ORM(对象关系映射)框架 Next.js和blazor server比较开发网站哪个好 Blazor Server和 Blazor WebAssembly区别 关于vue项目中cesium的地图显示问题 关于顺丰退出抖音电商退货业务事件的分析 在WINDOWS上创建NTP授时服务器,并验证是否可用 这样的算作“全栈技术”吗? 大疆上云APIdemo打包配置 用nssm将minio和srs注册成服务 LoRa定位技术和蓝牙AoA定位技术的关系 Mysql查询工具,你还用navcat吗? jar注册为服务的方式 nginx怎么样配置rtmp推流服务器
时间戳和时间格式互转
weipt · 2025-07-11 · via 博客园 - weipt
// Kafka 消息时间戳(UTC)
    var timestamp = result.Message.Timestamp;
    
    // 转换为 DateTime(UTC)
    DateTime utcTime = timestamp.UtcDateTime;
    
    // 转换为本地时间
    DateTime localTime = timestamp.UtcDateTime.ToLocalTime();
    
    // 格式化为字符串
    string formattedTime = localTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
    
    Console.WriteLine($"消息时间: {formattedTime}");
string timeString = "2023-10-01 12:34:56.789";

// 解析为 DateTime
DateTime localTime = DateTime.ParseExact(
    timeString, 
    "yyyy-MM-dd HH:mm:ss.fff", 
    CultureInfo.InvariantCulture
);

// 转换为 UTC 时间
DateTime utcTime = localTime.ToUniversalTime();

// 转换为 Kafka 时间戳(Confluent.Kafka)
var timestamp = new Timestamp(utcTime, TimestampType.CreateTime);

// 或者转换为 Unix 毫秒时间戳
long unixMillis = new DateTimeOffset(utcTime).ToUnixTimeMilliseconds();