5
在我的应用程序中,我需要以mm:ss格式显示已用时间。现在,我们必须对应用程序进行本地化。我们应该如何本地化这段时间?定位已用时间
在我的应用程序中,我需要以mm:ss格式显示已用时间。现在,我们必须对应用程序进行本地化。我们应该如何本地化这段时间?定位已用时间
您要使用的类NSDateFormatter:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:118800];
// Specifying a locale only for the purpose of this example
// if you don't specify one, it will use the user's locale, which is what you want
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: 4:00 AM
是不是一个冒号显示时间的普遍象征? 10:23法国和英格兰不一样吗? – 2011-04-05 23:56:57
你的意思应该是“5分钟”或“5分钟”或其他什么? – SVD 2011-04-05 23:57:48
是的......法语的格式是H'h'mm,德语的格式是H:mm'Uhr'。 – Abhinav 2011-04-06 00:07:21