NSDate与NSDateFormatter

树莓派通过TTL3.3转485 Modbus采集水表 所需道具 树莓派0,我用的是树莓派zero wh; 具有光电直读功能的有线水表,我用的是咸鱼淘的埃美柯LXSY-20E1; TTL3.3 转 485模块,带隔离的贵些; 5V转12V升压模块。 原理 树莓派有UART(GPIO14 Tx 和 GPIO15 Rx)串口通讯功能,电器特性是3.3V TTL,直读远传水表支持M-Bus/485通讯接口,我买的光电直读水表485要求12V供电(根据仪表厂家说明书)。TTL和485虽然都是串口通讯,但电器特性不一样,不能直接接!我已经烧掉一个树莓派... 阅读详情
1.NSDateFormatter配合NSDate与NSString之间的转化
 
NSDateFormatter有下面2个方法:
 
- (NSString *)stringFromDate:(NSDate*)date;//NSDate转NSString
 
- (NSDate *)dateFromString:(NSString*)string;//NSString转NSDate
 

e.g.
 
NSString *dateString=@"1900-01-01";
 
NSDateFormatter *dateFormatter=[[NSDateFormatteralloc]init];
 
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
 
NSDate *date=[dateFormatter dateFromString:dateString];
 
[dateFormatter release];

 
NSString转NSDate与上面类似
 
NSString *dateString=[dateFormatterdateFromString:[NSDate date]];

2.NSDateFormatter 的一些格式介绍
 
[dateFormattersetDateFormat:@"yyyy年MM月dd日#EEEE"];EEEE为星期几,EEE为周几
 
[dateFormatter setDateFormat:@"yyyy-MM-ddHH:mm:ss"];
 
[dateFormattersetDateFormat:@"yyyy年MMMMd日"];//MMMM 为xx月,一个d可以省去01日前的0

3.NSString转NSDate少一天的解决办法
 
用下面这种格式化方式 
 
1.[dateFormatter setDateFormat:@"yyyy-MM-ddHH:mm:ss"]; 

 
2.
 
  NSCalendar *calendar =[NSCalendar currentCalendar];
 
  NSDateComponents *components =[calendar components:(NSDayCalendarUnit | NSMonthCalendarUnit|                                 NSYearCalendarUnit) fromDate:[NSDate date]];
 
  NSDate *todayDate = [calendardateFromComponents:components];

NSDate存储的是世界标准时(UTC),输出时需要根据时区转换为本地时间
Dates
NSDate类提供了创建date,比较date以及计算两个date之间间隔的功能。Date对象是不可改变的。
如果你要创建date对象并表示当前日期,你可以alloc一个NSDate对象并调用init初始化:
view plain
NSDate *now = [[NSDate alloc] init];

或者使用NSDate的date类方法来创建一个日期对象。如果你需要与当前日期不同的日期,你可以使用NSDate的initWithTimeInterval...或dateWithTimeInterval...方法,你也可以使用更复杂的calendar或date components对象。
创建一定时间间隔的NSDate对象:
view plain
NSTimeInterval secondsPerDay = 24 * 60 * 60;

NSDate *tomorrow = [[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerDay];

NSDate *yesterday = [[NSDate alloc] initWithTimeIntervalSinceNow:-secondsPerDay];

[tomorrow release];
[yesterday release];

使用增加时间间隔的方式来生成NSDate对象:
view plain
NSTimeInterval secondsPerDay = 24 * 60 * 60;

NSDate *today = [[NSDate alloc] init];
NSDate *tomorrow, *yesterday;

tomorrow = [today dateByAddingTimeInterval: secondsPerDay];
yesterday = [today dateByAddingTimeInterval: -secondsPerDay];

[today release];

如果要对NSDate对象进行比较,可以使用isEqualToDate:, compare:, laterDate:和 earlierDate:方法。这些方法都进行精确比较,也就是说这些方法会一直精确比较到NSDate对象中秒一级。例如,你可能比较两个日期,如果他们之间的间隔在一分钟之内则认为这两个日期是相等的。在这种情况下使用,timeIntervalSinceDate:方法来对两个日期进行比较。下面的代码进行了示例:
view plain
if (fabs([date2 timeIntervalSinceDate:date1]) < 60) ...

NSCalendar & NSDateComponents
日历对象封装了对系统日期的计算,包括这一年开始,总天数以及划分。你将使用日历对象对绝对日期与date components(包括年,月,日,时,分,秒)进行转换。
NSCalendar定义了不同的日历,包括佛教历,格里高利历等(这些都与系统提供的本地化设置相关)。NSCalendar与NSDateComponents对象紧密相关。
你可以通过NSCalendar对象的currentCalendar方法来获得当前系统用户设置的日历。
view plain
NSCalendar *currentCalendar = [NSCalendar currentCalendar];

NSCalendar *japaneseCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSJapaneseCalendar];

NSCalendar *usersCalendar = [[NSLocale currentLocale] objectForKey:NSLocaleCalendar];
usersCalendar和currentCalendar对象是相等的,尽管他们是不同的对象。
你可以使用NSDateComponents对象来表示一个日期对象的组件——例如年,月,日和小时。如果要使一个NSDateComponents对象有意义,你必须将其与一个日历对象相关联。下面的代码示例了如何创建一个NSDateComponents对象:
view plain
NSDateComponents *components = [[NSDateComponents alloc] init];

[components setDay:6];
[components setMonth:5];
[components setYear:2004];

NSInteger weekday = [components weekday]; // Undefined (== NSUndefinedDateComponent)

要将一个日期对象解析到相应的date components,你可以使用NSCalendar的components:fromDate:方法。此外日期本身,你需要指定NSDateComponents对象返回组件。
view plain
NSDate *today = [NSDate date];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:today];

NSInteger day = [weekdayComponents day];
NSInteger weekday = [weekdayComponents weekday];

同样你也可以从NSDateComponents对象来创建NSDate对象:
NSDateComponents *components = [[NSDateComponents alloc] init];

[components setWeekday:2]; // Monday
[components setWeekdayOrdinal:1]; // The first Monday in the month
[components setMonth:5]; // May
[components setYear:2008];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDate *date = [gregorian dateFromComponents:components];

为了保证正确的行为,您必须确保使用的组件在日历上是有意义的。指定“出界”日历组件,如一个-6或2月30日在公历中的日期值产生未定义的行为。
你也可以创建一个不带年份的NSDate对象,这样的操作系统会自动生成一个年份,但在后面的代码中不会使用其自动生成的年份。
view plain
NSDateComponents *components = [[NSDateComponents alloc] init];

[components setMonth:11];
[components setDay:7];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDate *birthday = [gregorian dateFromComponents:components];

下面的示例显示了如何从一个日历置换到另一个日历:
view plain
NSDateComponents *comps = [[NSDateComponents alloc] init];

[comps setDay:6];
[comps setMonth:5];
[comps setYear:2004];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDate *date = [gregorian dateFromComponents:comps];

[comps release];
[gregorian release];

NSCalendar *hebrew = [[NSCalendar alloc] initWithCalendarIdentifier:NSHebrewCalendar];

NSUInteger unitFlags = NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit;

NSDateComponents *components = [hebrew components:unitFlags fromDate:date];

NSInteger day = [components day]; // 15
NSInteger month = [components month]; // 9
NSInteger year = [components year]; // 5764

历法计算
在当前时间加上一个半小时:
view plain
NSDate *today = [[NSDate alloc] init];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];

[offsetComponents setHour:1];
[offsetComponents setMinute:30];

// Calculate when, according to Tom Lehrer, World War III will end
NSDate *endOfWorldWar3 = [gregorian dateByAddingComponents:offsetComponents toDate:today options:0];

获得当前星期中的星期天(使用格里高利历):
view plain
NSDate *today = [[NSDate alloc] init];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

// Get the weekday component of the current date
NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:today];

/*
Create a date components to represent the number of days to subtract from the current date.

The weekday value for Sunday in the Gregorian calendar is 1, so subtract 1 from the number of days to subtract from the date in question. (If today is Sunday, subtract 0 days.)
*/

NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init];

[componentsToSubtract setDay: 0 - ([weekdayComponents weekday] - 1)];

NSDate *beginningOfWeek = [gregorian dateByAddingComponents:componentsToSubtract toDate:today options:0];

/*
Optional step:
beginningOfWeek now has the same hour, minute, and second as the original date (today).

To normalize to midnight, extract the year, month, and day components and create a new date from those components.
*/

NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: beginningOfWeek];

beginningOfWeek = [gregorian dateFromComponents:components];
如何可以计算出一周的第一天(根据系统的日历设置):
view plain
NSDate *today = [[NSDate alloc] init];

NSDate *beginningOfWeek = nil;

BOOL ok = [gregorian rangeOfUnit:NSWeekCalendarUnit startDate:&beginningOfWeek interval:NULL forDate: today];

获得两个日期之间的间隔:
view plain
NSDate *startDate = ...;
NSDate *endDate = ...;

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSUInteger unitFlags = NSMonthCalendarUnit | NSDayCalendarUnit;

NSDateComponents *components = [gregorian components:unitFlags fromDate:startDate toDate:endDate options:0];

NSInteger months = [components month];
NSInteger days = [components day];
使用Category来计算同一时代(AD|BC)两个日期午夜之间的天数:
view plain
@implementation NSCalendar (MySpecialCalculations)

-(NSInteger)daysWithinEraFromDate:(NSDate *) startDate toDate:(NSDate *) endDate {
NSInteger startDay=[self ordinalityOfUnit:NSDayCalendarUnit inUnit: NSEraCalendarUnit forDate:startDate];

NSInteger endDay=[self ordinalityOfUnit:NSDayCalendarUnit inUnit: NSEraCalendarUnit forDate:endDate];

return endDay-startDay;
}

@end

使用Category来计算不同时代(AD|BC)两个日期的天数:
view plain
@implementation NSCalendar (MyOtherMethod)

-(NSInteger) daysFromDate:(NSDate *) startDate toDate:(NSDate *) endDate {

NSCalendarUnit units=NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;

NSDateComponents *comp1=[self components:units fromDate:startDate];
NSDateComponents *comp2=[self components:units fromDate endDate];

[comp1 setHour:12];
[comp2 setHour:12];

NSDate *date1=[self dateFromComponents: comp1];
NSDate *date2=[self dateFromComponents: comp2];

return [[self components:NSDayCalendarUnit fromDate:date1 toDate:date2 options:0] day];
}

@end

判断一个日期是否在当前一周内(使用格里高利历):
view plain
-(BOOL)isDateThisWeek:(NSDate *)date {

NSDate *start;
NSTimeInterval extends;

NSCalendar *cal=[NSCalendar autoupdatingCurrentCalendar];
NSDate *today=[NSDate date];

BOOL success= [cal rangeOfUnit:NSWeekCalendarUnit startDate:&start interval: &extends forDate:today];

if(!success)
return NO;

NSTimeInterval dateInSecs = [date timeIntervalSinceReferenceDate];
NSTimeInterval dayStartInSecs= [start timeIntervalSinceReferenceDate];

if(dateInSecs > dayStartInSecs && dateInSecs < (dayStartInSecs+extends)){
return YES;
}
else {
return NO;
}
}

NSDate 使用 ios时间的秒数

取当前时间的秒数

NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
long long int date = (long long int)time;
NSLog(@”date\n%d”, date); //1295322949
//把秒数转化成yyyy-MM-dd hh:mm:ss格式
NSDate *dd = [NSDate dateWithTimeIntervalSince1970:date];
NSLog(@”d:%@”,dd); //2011-01-18 03:55:49 +0000

//给一个时间秒数,取出对应的时间
NSString *s = @”1295355600000″; //对应21:00
NSDate *d = [NSDate dateWithTimeIntervalSince1970:[s doubleValue]/1000];
NSLog(@”dddd:%@”,d); //2011-01-18 13:00:00 +0000
NSDateFormatter *formatter1 = [[NSDateFormatter alloc] init];
[formatter1 setDateFormat:@"HH:mm"];
NSString *showtimeNew = [formatter1 stringFromDate:d];
NSLog(@”showtimeNew:%@”,showtimeNew); //21:00 比d的时间 +8小时
[formatter1 release];


1. 创建或初始化可用以下方法
用于创建NSDate实例的类方法有
+ (id)date;
返回当前时间
+ (id)dateWithTimeIntervalSinceNow:(NSTimeInterval)secs;
返回以当前时间为基准,然后过了secs秒的时间
+ (id)dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secs;
返回以2001/01/01 GMT为基准,然后过了secs秒的时间
+ (id)dateWithTimeIntervalSince1970:(NSTimeInterval)secs;
返回以1970/01/01 GMT为基准,然后过了secs秒的时间
+ (id)distantFuture;
返回很多年以后的未来的某一天。(比如你需要一个比现在(Now)晚(大)很长时间的时间值,则可以调用该方法。测试返回了4000/12/31 16:00:00)
+ (id)distantPast;
返回很多年以前的某一天。(比如你需要一个比现在(Now)早(小)大很长时间的时间值,则可以调用该方法。测试返回了公元前0001/12/31 17:00:00)

用于创建NSDate实例的实例方法有
- (id)addTimeInterval:(NSTimeInterval)secs;
返回以目前的实例中保存的时间为基准,然后过了secs秒的时间

用于初始化NSDate实例的实例方法有
- (id)init;
初始化为当前时间。类似date方法
初始化为以2001/01/01 GMT为基准,然后过了secs秒的时间。类似dateWithTimeIntervalSinceReferenceDate:方法
- (id)initWithTimeInterval:(NSTimeInterval)secs sinceDate:(NSDate *)refDate;
初始化为以refDate为基准,然后过了secs秒的时间
- (id)initWithTimeIntervalSinceNow:(NSTimeInterval)secs;
初始化为以当前时间为基准,然后过了secs秒的时间

2. 日期之间比较可用以下方法
- (BOOL)isEqualToDate:(NSDate *)otherDate;
与otherDate比较,相同返回YES
- (NSDate *)earlierDate:(NSDate *)anotherDate;
与anotherDate比较,返回较早的那个日期
- (NSDate *)laterDate:(NSDate *)anotherDate;
与anotherDate比较,返回较晚的那个日期
- (NSComparisonResult)compare:(NSDate *)other;
该方法用于排序时调用:
. 当实例保存的日期值与anotherDate相同时返回NSOrderedSame
. 当实例保存的日期值晚于anotherDate时返回NSOrderedDescending
. 当实例保存的日期值早于anotherDate时返回NSOrderedAscending

3. 取回时间间隔可用以下方法
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)refDate;
以refDate为基准时间,返回实例保存的时间与refDate的时间间隔
- (NSTimeInterval)timeIntervalSinceNow;
以当前时间(Now)为基准时间,返回实例保存的时间与当前时间(Now)的时间间隔
- (NSTimeInterval)timeIntervalSince1970;
以1970/01/01 GMT为基准时间,返回实例保存的时间与1970/01/01 GMT的时间间隔
- (NSTimeInterval)timeIntervalSinceReferenceDate;
以2001/01/01 GMT为基准时间,返回实例保存的时间与2001/01/01 GMT的时间间隔
+ (NSTimeInterval)timeIntervalSinceReferenceDate;
以2001/01/01 GMT为基准时间,返回当前时间(Now)与2001/01/01 GMT的时间间隔

4. 将时间表示成字符串
- (NSString *)description;
以YYYY-MM-DD HH:MM:SS ±HHMM的格式表示时间。(其中 “±HHMM” 表示与GMT的存在多少小时多少分钟的时区差异。比如,若时区设置在北京,则 “±HHMM” 显示为 “+0800″)


本地化
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];

NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:118800];

NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormatter setLocale:usLocale];

NSLog(@"Date for locale %@: %@",
      [[dateFormatter locale] localeIdentifier], [dateFormatter stringFromDate:date]);
// Output:
// Date for locale en_US: Jan 2, 2001

NSLocale *frLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"];
[dateFormatter setLocale:frLocale];
NSLog(@"Date for locale %@: %@",
      [[dateFormatter locale] localeIdentifier], [dateFormatter stringFromDate:date]);
// Output:
// Date for locale fr_FR: 2 janv. 2001

从一个 ASIN 看透亚马逊:商品模型背后的增长飞轮 在亚马逊电商体系中,每件商品背后都有一套严密的商品建模逻辑。本篇文章以“ASIN 的一生”为线索,系统拆解了亚马逊的商品模型:从飞轮战略出发,剖析 SDP(Single Detail Page)机制如何实现标准化展示;再到 ASIN 编码、父子变体结构与 Offer 分离模型,逐层解析商品信息如何被建构、聚合与呈现。通过图解与案例,文章帮助读者理解商品建品流程、同款聚合原则、价格控制机制等核心逻辑,避免常见运营误区,是一份面向运营、产品、技术人员的实用参考指南。 阅读详情

相关推荐

Element-UI全面入门与实战技巧

Element-UI 是一套基于 Vue 2.0 的桌面端组件库,由饿了么前端团队开发并维护。它提供了一系列丰富的 UI 组件,旨在帮助开发者快速构建高效、美观的 Vue 应用程序。Element-UI 是一款遵循 Ant Design 设计规范的 Vue UI 库,它涵盖了从按钮、输入框、选择器到表格、标签、进度条等众多常用的界面元素。Element-UI 的组件不仅功能全面,而且易于定制,使得开发者可以快速实现个性化的页面设计。Element-UI 的特点包括:在使用 Element-UI 之前,需要确

全世界的博客 2871

iphone——日期处理

Dates         NSDate类提供了创建date,比较date以及计算两个date之间间隔的功能。Date对象是不可改变的。         如果你要创建date对象并表示当前日期,你可以alloc一个NSDate对象并调用init初始化: NSDate *now = [[NSDate alloc] init];         或者使用NSDate的date类方法来创建一

lingedeng的专栏 1万+

THUCNews新闻文本分类-tfidf+sklearn

本文使用的是和鲸社区现有数据集,代码也在和鲸社区公开,fork之后可以直接运行。 本文中所用的数据集清华NLP组提供的THUCNews新闻文本分类数据集的一个子集(原始的数据集大约74万篇文档,训练起来需要花较长的时间)。 本次训练使用了其中的体育, 财经, 房产, 家居, 教育, 科技, 时尚, 时政, 游戏, 娱乐10个分类,每个分类6500条,总共65000条新闻数据。项目在和鲸社区的平台上跑的,数据集直接引用了和鲸的数据集,每个分类6500条,总共65000条新闻数据。 数据集划分如下: cnews

wmq104的博客 4594

获取本机/本地精准时间、根据date获取周几,下周日期

1、获取本地精准时间(UTC → 本机) //获取准确日期和时间(UTC → 本地) + (NSString *)getNowDateAndTime { NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; NSDate *newDate = [[NSCalendar currentCalend...

咖啡丶丶不加糖的博客 1315

泛微OA与金蝶云星空深度集成实战:审批与表单双场景解析

本文深入解析泛微OA与金蝶云星空的深度集成实战,聚焦审批流程与表单对接两大核心场景。通过具体案例,详细阐述了如何实现业务数据与审批流程的自动联动,打破数据孤岛,提升企业运营效率与数据一致性,并分享了接口设计、安全策略及实战避坑指南。

4k5l6j7h8的博客 475

STM32裸机开发基础:寄存器直接操作详解

寄存器是微控制器内部的特殊存储单元,直接与硬件电路连接,用于控制和监视硬件功能。与普通内存不同,寄存器的每一位(bit)通常都有特定的硬件含义。寄存器就是机器的控制面板上的各种开关和指示灯每个开关控制一个具体功能(如打开LED、启动通信)每个指示灯显示一个具体状态(如数据接收完成、错误发生)// GPIO引脚定义1。

2401_88760782的博客 2193

时间与日期处理

主要有以下类: NSDate -- 表示一个绝对的时间点NSTimeZone -- 时区信息NSLocale -- 本地化信息NSDateComponents -- 一个封装了具体年月日、时秒分、周、季度等的类NSCalendar -- 日历类,它提供了大部分的日期计算接口,并且允许您在NSDate和NSDateComponents之间转换NSDateFormatter -- 用来在日期和字符串之...

weixin_30875157的博客 441

手把手教你设计反激开关电源:从整流滤波到PCB布局的实战避坑指南

本文是一份反激开关电源的实战设计指南,重点解析了从整流滤波电路到PCB布局的关键细节与常见陷阱。文章深入探讨了输入保护元件协同设计、EMI滤波器优化、整流桥与滤波电容选型,并详细阐述了如何通过优化PCB布局来确保安规、最小化功率回路面积以控制噪声,旨在帮助工程师和爱好者规避设计误区,提升电源的可靠性与性能。

yhn45678901的博客 698

iOS 官方文档 NSCalendar

一、系统区域信息[NSCalendar currentCalendar] [NSCalendar autoupdatingCurrentCalendar]比如设定成「日本日历」的时候、currentCalendar的值是NSJapaneseCalendar 设定成「公历」的时候、currentCalendar的值是NSGregorianCalendar注意:在程序中,currentCalenda

长沙火山 4091

Palantir 产品架构深度解析:从本体到AI的决策智能平台

本文深度解析了Palantir决策智能平台的核心产品架构。其核心在于构建企业级的“本体”(Ontology),即业务世界的“数字孪生”,通过数据、逻辑、操作三层抽象统一语义。平台以此为基础,通过Foundry构建数字孪生,并通过AIP(人工智能平台)实现本体增强生成(OAG),将AI深度融入业务,形成从数据感知、智能分析到行动执行的完整决策闭环。

ooo22的博客 740

【知识分享】CAN总线中终端网络的重要性

P沟道和N沟道晶体管的漏源通态电阻匹配良好时,形成的CANH和CANL信号匹配良好;如果驱动器的一半具有比另一半低得多的导通状态电阻,那么总线共模电压将从VCC/2的显性状态偏离,并回到VCC/2的隐性状态,这将导致每一次状态转换都会伴随着共模电压噪声,从而导致更高水平的传导和辐射能量发射。

一只豌豆象的博客 1549

iOS开发-格式化时间显示刚刚几分钟前几小时前等

iOS开发-格式化时间显示刚刚几分钟前几小时前等在开发中经常遇到从服务端获取的时间戳,需要转换显示刚刚、几分钟前、几小时前、几天前、年月日等格式。主要用到了NSCalendar、NSDateComponents这两个类。

一名开发者 1630

lammps教程:非晶sio2建模方法

大家好,我是小马老师。 本文介绍非晶sio2的建模方法。 sio2的建模方法有很多,可以下载cif文件使用atomsk转为data文件,也可以直接在ms中导入sio2结构,这些方法建的sio2都是标准的sio2晶体。 如果要建立非晶状态的sio2,就是把排列规则的sio2变成无序排列的sio2。 非晶建模方法有很多,在lammps中,可以通过高温高压的方法打乱sio2的排列实现非晶建模。 代码中的温度和步数可根据需要自己调整。 下面给出in文件案例代码。 units metal atom

lammps_jiayou的博客 5276

NSDate, NSDateFormatter的使用

//NSDate         //创建对象         //通过NSDate创建的对象, 获取的是0时区的时间         NSDate * date = [NSDate date];         NSLog(@"%@", date);         //获取明日此时的时间         NSDate * tomorrow = [NSDate dateWithT

iOS开发者洛松的博客 1168

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

NSDate和NSDateFormatter

NSDate和NSDateFormatter 在iOS开发中,NSDate的使场景很多,例如:聊天程序里:二分钟前,昨天,几天前的计算;网络请求中的时间戳; NSDate是Cocoa中用于处理日期和时间的基础类,封装了某一给定的时刻(含⽇期,时间,时区)。 使用+date方法获取当前时间 例如:NSDate *nowDate = [NSDate date]; 注意NSLog(@“%@”,

xxl521zhy的专栏 508

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

OC:NSDate和NSDateFormatter的知识点

NSDate和NSDateFormatter的知识点

742

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

NSDate NSDateFormatter NSTimeZone NSDateComponents NSCalendar

--------------------------------------------------------------------------NSDate---------------------------------------------------------------------------- NSDate:用来获取系统运行时时间. 1:获取IOS当前的运行时间

余书懿 1552

NSDate, NSCalendarDate, NSDateFormatter用法

objective-c 编程总结(第四篇)日期型类型操作 获取当前日期:NSDate * date = [NSDate date];//不过这个方式,获取的是UTC事件。 NSDate * date = [NSCalendarDate date];//获取本地时间。 获取昨天的日期: NSDate * yesterday = [[NSCalendarDate date] dateB

LuckyCat7848的专栏 724

Objective-C_NSDate、NSDateFormatter

讲解NSDate、NSDateFormatter的使⽤。

谁见过风的专栏 1660

NSDate与NSDateFormatter的相关用法

1.NSDateFormatter配合NSDate与NSString之间的转化 NSDateFormatter有下面2个方法: - (NSString *)stringFromDate:(NSDate *)date;//NSDate转NSString - (NSDate *)dateFromString:(NSString *)string;//NSString转NSDate e.

清雨小竹 1850

NSDate 和 NSDateFormatter 转换

//1.利用NSDateFormatter将日期按照一定格式输出:转换成字符串         /*         NSDate *date = [NSDate date];         NSDateFormatter *fra = [[NSDateFormatter alloc] init];         [fra setDateFormat:@"yyyy-MM-

光远的iOS开发专题 692

关于NSDate和NSDateFormatter的几个常用方法

/** * NSDate常见类方法 */ // 获得当前时间 NSDate *date1 = [NSDate date]; // 类方法 // NSDate *date1 = [[NSDate alloc] init]; // 初始化方法 NSLog(@"%@", date1); // 在当前日期基础上加上120秒(在OC中时间大多数都是秒)...

a747746的博客 180

OC -- NSDate和NSDateFormatter小结

这里要使用ios有关的日期时间api:(NSTimeInterval)是浮点型数,可精确到毫秒,1秒=1000毫秒 NSDate,类似java里面的Date对象,是对从1970-1-1毫秒数的封装,可记录时间;NSDateFormatter,类似java中的DateFormat相关的api,用于日期对象的格式化或者字符串解析为日期对象。   首先,创建一个日期格式化对象: NSDa

jy578154186_的专栏 2281

NSDate与NSDateFormatter 以及设置时区

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34097242的博客 1292

OC学习之道:关于NSDate和NSDateFormatter类的使用

// // main.m // Copyright (c) 2015年 tongxing. All rights reserved. // int main(int argc, const char * argv[]) { @autoreleasepool { #pragma mark----NSDate的使用 //1.获取当前时间 NSDate *new

朝夕 887

iOS NSDate NSDateFormatter

日期格式化: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *endDate = [dateFormatter dateFromStri

yangtb2010的专栏 591
上一篇: 向Xcode加入字体
下一篇: 计算地图上两点距离 汇总
focusjava
博客等级 码龄14年 127粉丝 528原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址