当前位置: 首页 > news >正文

ios CCNSDate.m

//
//  CCNSDate.h
//  CCFC
//
//  Created by xichen on 11-12-17.
//  Copyright 2011年 ccteam. All rights reserved.
//#import <Foundation/Foundation.h>@interface NSDate(cc)// 获取系统时间(yyyy-MM-dd HH:mm:ss.SSS格式)
+ (NSString *)getSystemTimeStr;// print current time using printf func
+ (void)printCurrentTime;// print the system date by chinese format
+ (void)printSystemDateByChineseFormat;@end

 

//
//  CCNSDate.m
//  CCFC
//
//  Created by xichen on 11-12-17.
//  Copyright 2011年 ccteam. All rights reserved.
//#import "CCNSDate.h"@implementation NSDate(cc)// 获取系统时间(yyyy-MM-dd HH:mm:ss.SSS格式)
+ (NSString *)getSystemTimeStr
{NSDateFormatter *dateFormatter = [NSDateFormatter new];[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];       // 设置格式为年-月-日 时:分:秒.毫秒NSString *timeStr = [dateFormatter stringFromDate:[NSDate date]];[dateFormatter release];return timeStr;
}// print current time using printf func
+ (void)printCurrentTime
{printf("Current Time is %s\n", [[self getSystemTimeStr] UTF8String]);
}// print the system date by chinese format
+ (void)printSystemDateByChineseFormat
{NSDateFormatter *formatter = [[NSDateFormatter alloc] init];//NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//[formatter setLocale:locale];//[locale release];[formatter setDateFormat:@"YYY年MM月d日EEEE"];NSDate *date = [NSDate date];NSLog(@"%@", [formatter stringFromDate:date]);[formatter release];
}@end


微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。

我是程序员小迷(致力于C、C++、Java、Kotlin、Android、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

欢迎关注。助您在编程路上越走越好!

http://www.lryc.cn/news/391059.html

相关文章:

  • Windows系统安装SSH服务结合内网穿透配置公网地址远程ssh连接
  • 虚拟机与主机的联通
  • 2024年中国网络安全市场全景图 -百度下载
  • Linux脚本自动安装 docker
  • 【计算智能】遗传算法(一):基本遗传算法(SGA)理论简介
  • win10系统让当前用户拥有管理员权限
  • Redis持久化的三种方式(RDB、AOF和混合)
  • Telnet发送get/post请求
  • PostgreSQL匹配字符串方法
  • Docker镜像加速配置
  • 【elementui】记录解决el-tree开启show-checkbox后,勾选一个叶结点后会自动折叠的现象
  • 用Vue3和Plotly.js绘制交互式3D烛形图
  • git上传文件
  • Redis 7.x 系列【16】持久化机制之 AOF
  • 使用 PostGIS 生成矢量图块
  • WebSocket 心跳机制如何实现
  • Docker 容器连接
  • 【C语言】continue 关键字
  • Taro + vue3 中微信小程序中实现拉起支付
  • 003-GeoGebra如何无缝嵌入到PPT里
  • AI:开发者的朋友还是对手?
  • 如何在Android Studio中查看APP客户端日志
  • 2024微信小程序期末大作业-点奶茶微信小程序(后端nodejs-server)(附下载链接)_微信小程序期末大作业百度网盘下载
  • Qt:4.信号和槽
  • Ubuntu20.04更新GLIBC到2.35版本
  • Qt 实战(7)元对象系统 | 7.1、简介
  • iOS 真机打包,证书报错No signing certificate “iOS Distribution” found
  • 2024年7月3日 (周三) 叶子游戏新闻
  • linux守护进程生命周期管理-supervisord
  • rtpengine_mr12.0 基础建设容器运行