here I used one label at top to display the today month with year. And also I have 6 label which will display the todays date like say 31dec to 5 Jan. Here is the code:
This will display the todays date from next 5 date
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel];
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < 6; ++i) {
NSDate *nextDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:i toDate:today options:nil];
UILabel *label = (UILabel *)labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
}
This will display the current month with year
// show the present month
NSDate *date = [NSDate date];
// NSDateFormatter *date = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat=#"MMMM";
NSString * monthString = [[dateFormatter stringFromDate:date] capitalizedString];
dateFormatter.dateFormat=#"yyyy";
NSString * yearString = [[dateFormatter stringFromDate:date] capitalizedString];
dateLabel.text = [NSString stringWithFormat:#"%# ,%#",monthString,yearString];
Important:
what I need is I need to display like below image:
The current date should display at last and should show previous 5 dates before.
I have two button at left and right. when ever user press right button like say now its 31Dec. And when user press right it should change to 1Jan and should display the previous 5 date from Jan 1. And also the month .label should automatically change to Jan,2016. Like below image:
Two button action:
- (IBAction)calRight:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
}
- (IBAction)calLeft:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:-1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
}
This code I did for changing only month I tried. But no changing my date label.
Please explain me in code.
Full Edited:
- (void)viewDidLoad {
[super viewDidLoad];
NSDate *firstLabelDate = [NSDate date]; //make it class variable
NSDate *lastLabelDate = [NSDate date]; //make it class variable
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel]; //make it class variable
[self updateDateLabelsGoingForward:YES andFromDay:self.lastLabelDate];
}
- (IBAction)calRight:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
[self updateDateLabelsGoingForward:YES andFromDay:self.lastLabelDate];
}
- (IBAction)calLeft:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:-1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
[self updateDateLabelsGoingForward:NO andFromDay:self.firstLabelDate];
}
- (void)updateDateLabelsGoingForward:(BOOL) goForward andFromDay:(NSDate*) dayFrom {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < 6; ++i) {
int dateToBeModified = goForward?1:-1;
NSDate *nextDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:dateToBeModified toDate:dayFrom options:nil];
UILabel *label = (UILabel *)self.labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
if(i==5){
self.lastLabelDate = nextDate;
}
if(i==0){
self.firstLabelDate = nextDate;
}
}
}
Define one Date object globally NSDate *firstdate; and assign its value in viewDidLoad firstdate = [NSDate date];
now use following method to show your dates & month call this method from viewDidLoad [self dateChange];
-(void)dateChange
{
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < 6; ++i) {
NSDate *nextDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:i toDate:firstdate options:nil];
UILabel *label = (UILabel *)labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
if (i==5) {
dateFormatter.dateFormat=#"MMMM";
NSString * monthString = [[dateFormatter stringFromDate:nextDate] capitalizedString];
dateFormatter.dateFormat=#"yyyy";
NSString * yearString = [[dateFormatter stringFromDate:nextDate] capitalizedString];
dateLabel.text = [NSString stringWithFormat:#"%# ,%#",monthString,yearString];
}
}
}
now set your calRight and calLeft as bellow
- (IBAction)calRight:(id)sender {
firstdate = [NSDate dateWithTimeInterval:86400 sinceDate:firstdate];
[self dateChange];
}
- (IBAction)calLeft:(id)sender {
firstdate = [NSDate dateWithTimeInterval:-86400 sinceDate:firstdate];
[self dateChange];
}
First create an array which will store date's for 6 days...NSArray *dates.
Then initialise it with [NSDate date] at dates[0].
Use NSDateComponents and subtract the date component and store the previous 5 days in the array from dates[1.....4].
On click of the button you can increment or decrement the entire array and display the dates all again....
Pretty simple actually you are almost there, add one more variable that will hold the last date displayed in the last label, let us not mess up by taking the date out of the label via NSDateFormatter etc. long route!
NSDate *firstLabelDate = [NSDate date]; //make it class variable
NSDate *lastLabelDate = [NSDate date]; //make it class variable
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel]; //make it class variable
[self updateDateLabelsGoingForward:YES andFromDay:self.lastLabelDate];
And your button actions should be modified as below,
- (IBAction)calRight:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
[self updateDateLabelsGoingForward:YES andFromDay:self.lastLabelDate];
}
- (IBAction)calLeft:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMMM,yyyy"];
NSDate *tempDate = [dateFormat dateFromString:dateLabel.text];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:-1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:tempDate options:0];
dateLabel.text = [dateFormat stringFromDate:newDate];
[self updateDateLabelsGoingForward:NO andFromDay:self.firstLabelDate]
}
Add a common method to reload your date labels.
- (void)updateDateLabelsGoingForward:(BOOL) goForward andFromDay:(NSDate*) dayFrom {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < 6; ++i) {
int dateToBeModified = goForward?(1*i):(-1*i);
NSDate *nextDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:dateToBeModified toDate:dayFrom options:nil];
UILabel *label = (UILabel *)self.labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
if(i==5){
self.lastLabelDate = nextDate;
}
if(i==0){
self.firstLabelDate = nextDate;
}
}
}
Hope this helps, and this could help you in the longer run.
Related
My concern is..if am having text field with start date.when i am selecting date from calendar with day of Friday..then i want to skip weekend days saturday and sunday in enddate text field...i tried like this
NSString *strCurrentDate;
NSString *strNewDate;
NSDate *date = [NSDate date];
NSDateFormatter *df =[[NSDateFormatter alloc] init];
[df setDateFormat:#"yyyy-MM-dd"];
[df setTimeStyle:NSDateFormatterMediumStyle];
strCurrentDate = [df stringFromDate:date];
NSLog(#"Current Date and Time: %#",strCurrentDate);
int hoursToAdd = roundedUp;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:hoursToAdd];
NSDate *newDate= [calendar dateByAddingComponents:components toDate:date options:0];
[df setDateFormat:#"yyyy-MM-dd"];
[df setTimeStyle:NSDateFormatterMediumStyle];
strNewDate = [df stringFromDate:newDate];
NSLog(#"New Date and Time: %#",strNewDate);
while ([strNewDate compare:strCurrentDate] == NSOrderedAscending)
{
NSDateComponents *dateComponents = [calendar components:NSWeekdayCalendarUnit fromDate:strNewDate];
if (dateComponents.weekday == friday)
{
count = count+2;
NSLog(#"count = %d", count);
NSDateComponents *oneDay = [[NSDateComponents alloc] init];
[oneDay setDay:2];
NSString *endDate = [strNewDate dateByAddingTimeInterval:2*60*60*24];
// [oneDay setDay:2];
}
}
But I am not getting only week days… so can any one do the needful… thank u in advance :)
To get the next working day from now use the method isDateInWeekend of NSCalendar
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
// Strip the time portion of the date
NSDate *date = [calendar startOfDayForDate:[NSDate date]];
do {
// add 1 day until the result is not in a weekend
date = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:date options:NSCalendarMatchNextTime];
} while (![calendar isDateInWeekend:date]);
NSLog(#"Next Workday: %#", date);
I have some 6 UILabels which will show the date like below:
Jan,2016 (label)
(button) < **27Dec 28Dec 29Dec 30Dec 31Dec 1Jan** >(Button)
Also I am having two arrow UIButton at both side when user can move to back date or previous date. And i have one lable to show the current month based on my date showing
Here is my full code:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
firstdate = [NSDate date];
firstdate = [NSDate dateWithTimeInterval:-(5*86400) sinceDate:firstdate];
[self dateChange];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MMM,yyyy"]; dateLabel.text = [dateFormat stringFromDate:[NSDate date]];
dateLabel.text = [dateFormat stringFromDate: firstdate];
}
-(void)dateChange
{
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < 6; ++i) {
NSDate *nextDate = [calendar dateByAddingUnit: NSCalendarUnitDay value:i toDate:firstdate options:nil];
UILabel *label = (UILabel *)labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
if (i==5) {
dateFormatter.dateFormat=#"MMM,yyyy";
dateLabel.text = [[dateFormatter stringFromDate:nextDate] capitalizedString];
}
}
}
- (IBAction)calRight:(id)sender {
firstdate = [NSDate dateWithTimeInterval:86400 sinceDate:firstdate];
[self dateChange];
}
- (IBAction)calLeft:(id)sender {
firstdate = [NSDate dateWithTimeInterval:-86400 sinceDate:firstdate];
[self dateChange];
}
So what I need in .For example like says - today is Jan 1 .so if user open my app they will seeJan 1 at last date followed by previous december date at back like I mention above .
So in that case if user on current datemeans like Jan1 means then my Rightbuttonshould be disabled. At the same time when user use left button to go november month menas then my right buttonshould be enabled
Only my rightbuttonshould be disabled when user in current date.
Please help me to solve I have an idea that !
if (some condition)
[leftBtn setEnabled:NO];
else
[leftBtn setEnabled:YES];
But I am not sure about condition and code.
Change your method dateChange with bellow code and also btnRight is your right side button so change name whatever you have give for it.
-(void)dateChange
{
NSArray *labelArray = #[flabel, slabel, tlabel, folabel, fivlabel,sixlabel];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *calendar = [NSCalendar currentCalendar];
dateFormatter.dateFormat = #"ddMMM";
for (NSInteger i = 0; i < labelArray.count; ++i) {
NSDate *nextDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:i toDate:firstdate options:nil];
UILabel *label = (UILabel *)labelArray[i];
label.text = [dateFormatter stringFromDate:nextDate];
if (i==(labelArray.count-1)) {
dateFormatter.dateFormat=#"MMM,yyyy";
dateLabel.text = [[dateFormatter stringFromDate:nextDate] capitalizedString];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"yyyy-MM-dd"];
if ([[dateFormat stringFromDate:nextDate] isEqualToString:[dateFormat stringFromDate:[NSDate date]]])
btnRight.enabled = false; //It's the same day
else
btnRight.enabled = true;
}
}
}
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"yyyy-MM-dd hh:mm:ss"];//You Can Change Date Format
NSString *strDate=[dateFormatter stringFromDate:[NSDate date]];
[btnYourButton setEnabled:([strDate isEqualToString:txtYourTextFieldDate.text])?NO:YES];
NSCalendar has a very convenient method to check if today contains a specific date.
rightButton.enabled = ![[NSCalendar currentCalendar] isDateInToday:aDate];
Important note:
Never ever do date math using the 86400 constant
Consider that on a day where daylight saving time changes a day doesn't have 86400 seconds.
For example instead of
firstdate = [NSDate date];
firstdate = [NSDate dateWithTimeInterval:-(5*86400) sinceDate:firstdate];
write
firstdate = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitDay value:-5 toDate:[NSDate date] options:nil];
I have get Sequence of month using following code
NSDate *aDate = [NSDate dateWithTimeInterval:row*30*24*60*60 sinceDate:self.earliestPresentedDate];
NSDateComponents *components = [self.calendar components:(NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:[NSDate date]];
NSDate *today = [self.calendar dateFromComponents:components];
components = [self.calendar components:(NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:aDate];
NSDate *otherDate = [self.calendar dateFromComponents:components];
if ([today isEqualToDate:otherDate]) {
} else {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.locale = [NSLocale currentLocale];
formatter.dateFormat = #"MMM ";
[lblDate setText:[formatter stringFromDate:aDate]];
}
i want to get Sequence of year how to get...please give solution
Make one function which gives to date of next year as below,
NSDateComponents *dayComponent = [[NSDateComponents alloc] init];
dayComponent.year = +1;
NSCalendar *theCalendar = [NSCalendar currentCalendar];
NSDate *newDate = [theCalendar dateByAddingComponents:dayComponent toDate:[NSDate date] options:0];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.locale = [NSLocale currentLocale];
formatter.dateFormat = #"yyyy";
NSString *strDate = [formatter stringFromDate:newDate];
NSLog(#"%#",strDate);
Set this date in your label.
above I am passing current date so I Will get year : 2016.
Simple way, it logs this and the subsequent 7 years.
NSInteger howManyYears = 8;
NSInteger thisYear = [[NSCalendar currentCalendar] component:NSCalendarUnitYear fromDate:[NSDate date]];
for (NSInteger i = 0; i < howManyYears; ++i) {
NSLog(#"%ld", thisYear++);
}
or to get an array of strings
NSMutableArray *theYears = [NSMutableArray array];
NSInteger howManyYears = 8;
NSInteger thisYear = [[NSCalendar currentCalendar] component:NSCalendarUnitYear fromDate:[NSDate date]];
for (NSInteger i = 0; i < howManyYears; ++i) {
[theYears addObject:[NSString stringWithFormat:#"%ld", thisYear++]];
}
NSLog(#"%#", theYears);
i am trying to implement calendar. i have one label for year and two buttons for incrementing and decrementing year from calendar. i am getting this exception (Thread1: EXC_BAD_ACCESS(code=1,address=0x5146a345)) while clicking button(increment or decrement)my requirement is if i click right button my year should increase as well as if i click left button my year should decrease. my exception line is date = [cal dateByAddingUnit:NSCalendarUnitYear value:1 toDate:date options:0]; could you please help to resolve this issue. this is my code
- (void)viewDidLoad
{
[super viewDidLoad];
date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"YYYY"];
NSString *stringFromDate = [formatter stringFromDate:date];
yar1.text=stringFromDate;
}
- (IBAction)right:(id)sender {
NSCalendar *cal = [NSCalendar currentCalendar];
date = [cal dateByAddingUnit:NSCalendarUnitYear value:1 toDate:date options:0];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"YYYY"];
NSString *stringFromDate = [formatter stringFromDate:date];
yar1.text=stringFromDate;
}
- (IBAction)left:(id)sender {
NSCalendar *cal = [NSCalendar currentCalendar];
date = [cal dateByAddingUnit:NSCalendarUnitYear value:1 toDate:date options:0];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"YYYY"];
NSString *stringFromDate = [formatter stringFromDate:date];
yar1.text=stringFromDate;
}
You need a date component to change the date like this,
-(NSDate *)offsetYear:(int)numOfYears date:(NSDate*)date
{
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setYear:numOfYears];
return [[NSCalendar currentCalendar] dateByAddingComponents:offsetComponents
toDate:date options:0]; }
Pass the offset as 1 for right and -1 for left
I'm struggling to find a way to use NSDate for time only purposes.
I was trying to do the following code:
- (void)awakeFromInsert
{
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.minute = 45;
comps.second = 0;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
self.periodDuration = [calendar dateFromComponents:comps];
NSLog(#"periodDuration: %#",self.periodDuration);
comps = [[NSDateComponents alloc] init];
comps.hour = 8;
comps.minute = 0;
self.firstPeriodStartTime = [calendar dateFromComponents:comps];
NSLog(#"firstPeriodTime: %#",self.periodDuration);
}
But the result I get is:
periodDuration: 0001-12-31 22:24:04 +0000
firstPeriodTime: 0001-12-31 22:24:04 +0000
The result I was expecting:
periodDuration: 45:00
firstPeriodTime: 08:00
What am I doing wrong? How can I fix this?
Thank you.
The log of date is misleading you, if you are forming a date with only a few components you will not get a proper date instance which uniquely identifies a date and time.
If you try with this code snipped you can find that if you are just converting the dates back to string it is just as you expect
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.minute = 45;
comps.second = 0;
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *periodDate = [calendar dateFromComponents:comps];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"mm:ss"];
NSLog(#"periodDuration: %#",[dateFormatter stringFromDate:periodDate]);
comps = [[NSDateComponents alloc] init];
comps.hour = 8;
comps.minute = 0;
NSDate *firstPeriodDate = [calendar dateFromComponents:comps];
[dateFormatter setDateFormat:#"HH:mm"];
NSLog(#"firstPeriodTime: %#",[dateFormatter stringFromDate:firstPeriodDate]);
periodDuration: 45:00
firstPeriodTime: 08:00
You can use NSDateFormatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"HH:mm"];
NSLog(#"%#",[dateFormatter stringFromDate:[NSDate date]]);
Use a NSTimeInterval (which is, basically, a double containing the number of seconds). To store it in CoreData:
[NSNumber numberWithDouble:myTimeInterval];
As for formatting: If you want more than 24h displayed, use this:
NSUInteger seconds = (NSUInteger)round(myTimeInterval);
NSString *formattedDate = [NSString stringWithFormat:#"%02u:%02u:%02u",
seconds / 3600, (seconds / 60) % 60, seconds % 60];
NSLog(#"%#", formattedDate);
If you don't want more than 24h, you can use NSDate and NSDateFormatter again:
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:myTimeInterval];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:#"HH:mm:ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:#"UTC"]];
NSString *formattedDate = [dateFormatter stringFromDate:date];
NSLog(#"%#", formattedDate);
NSString *timeString;
timeString = [NSDateFormatter localizedStringFromDate:[NSDate date]
dateStyle:NSDateFormatterNoStyle
timeStyle:NSDateFormatterMediumStyle];
12:03:54 PM