date-format

How to convert number to hour and minute in android

微笑、不失礼 提交于 2019-12-13 09:44:48
问题 In my application i should show hour and minute and i get this numbers from server with this sample : Json : { data:{ time:84561 } } i should get this number from time and show it with this format **hh : mm : ss** I can get number of time, but i can't convert this to **hh : mm : ss** . How can i it? 回答1: long timeSec= 84561;// Json output int hours = (int) timeSec/ 3600; int temp = (int) timeSec- hours * 3600; int mins = temp / 60; temp = temp - mins * 60; int secs = temp; String

Need help for specific date format

梦想的初衷 提交于 2019-12-13 08:59:30
问题 I have next date string, 2011-08-30T11:44:54.345-04:00 Help me to compose right format to parse it with dateFromString: 回答1: You need to eliminate the last colon (timezone, "-04:00" -> "-0400"), as Z will take something like "-0800", then you can give this a try: NSString *dateString = @"2011-08-30T11:44:54.345-04:00"; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyy-MM-ddEHH:mm:ss.SSSZ"]; NSDate *date = [dateFormat dateFromString:dateString];

Ruby on Rails I18n - Localization of Dates Works In localhost but Not In Production

情到浓时终转凉″ 提交于 2019-12-13 04:27:50
问题 I am using Ruby on Rails 3.2.13 Ruby 1.9.3. I have the following code in my en.yml file: date: formats: default: "%Y-%m-%d" short: "%b %d" long: "%A, %B %d, %Y" mmyy: "%B %Y" I have the following code in my fr.yml file: date: formats: default: "%Y-%m-%d" short: "%b %d" long: "%A, %d %B %Y" mmyy: "%B %Y" My date field media_created is stored in a string in YYYY-MM-DD format Here is the code in my view to display the short date format in my view: <%= l media_item.media_created.to_date, format:

How to convert Date in String to Sql date?

£可爱£侵袭症+ 提交于 2019-12-13 03:57:25
问题 This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 8 years ago . I have a date with String format "09-06-2011". I need to compare it with another date in java.sql.Date format "2011-06-30 00:00:00". How can I convert a String date to a sql date ? 回答1: Use str_to_date function in MySQL. http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date Format: mysql> SELECT STR_TO_DATE('01,5,2013','%d,

How to find format (not validate against a particular format) of date with moment.js

北慕城南 提交于 2019-12-13 03:17:12
问题 I have a given Date string, which is already formatted by moment.js by someone. I want to get that format. I have checked existing questions and came across this one - check format of date with moment.js The solution provided is not returning the format of the date. Rather it is validating against some given formats. I want a function getMomentDateFormat like this - var dateString = field.value; //"Nov 30, 2017" var dateFormat = getMomentDateFormat(dateString ); //I want dateFormat = "MMM DD,

Misbehaving of the date parsing in SimpleDateFormat

馋奶兔 提交于 2019-12-12 21:08:22
问题 I have a java class inside the jar file that is in a JBoss server which invoked through a bash file as follows. java -cp /com/site/domain/TimeFormatter.jar packOne.subPack.Test But I got an error when parsing the below date in there. java.text.ParseException: Unparseable date: "Wed, 29 Jan 2014 21:00:00 GMT" at java.text.DateFormat.parse(DateFormat.java:335) Java CODE : Date date = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z").parse("Sun, 26 Jan 2014 21:00:00 GMT"); System.out.println(

define the date format java 'rd' 'st' 'th' 'nd'

泄露秘密 提交于 2019-12-12 18:11:23
问题 I have a String "Saturday, Oct, 25th, 11:40" What format does this date has? How can I parse the ordinal indicator? Here is how i want to convert it private String changeDateFormat(String stringDate){ DateFormat dateFormat = new SimpleDateFormat("DD, MM, ddth, hh:mm"); try { Date date = dateFormat.parse(stringDate); dateFormat = new SimpleDateFormat("ddMMMyyyy"); stringDate=dateFormat.format(date); } catch (ParseException e) { e.printStackTrace(); } return stringDate.toUpperCase(); } 回答1:

strtotime() does not return correct value when specifying date in dd/mm/yyyy format

浪尽此生 提交于 2019-12-12 18:06:21
问题 I want to convert date 24/09/2010 in format dd/mm/yyyy to 2010-09-24 in format yyyy-mm-dd . This works: date("Y-m-d",strtotime("09/24/2010")); But this does not: date("Y-m-d",strtotime("24/09/2010")); // it returns '1970-01-01' Any idea why? 回答1: according to php, the valid php formats are stated here. So basically what you gave is invalid. Alternatively, you can use mktime, date_parse_from_format or date_create_from_format 回答2: strtotime does its best to guess what you mean when given a

iOS Date formatting

心已入冬 提交于 2019-12-12 17:21:02
问题 I need to have the following date formatted while using the application with an US locale: January 1st, July 2nd, November 28th How should I do that? Searched with NSDateFormatter , but I'm not able to set an appropriate format and default formats are too long. 回答1: NSDateFormatter *format = [[NSDateFormatter alloc] init]; [format setDateFormat:@"MMMM dd'st'"]; NSDate *now = [[NSDate alloc] init]; NSString *dateString = [format stringFromDate:now]; NSLog(@"%@",dateString); this will give you

Check if a string contains only date

蓝咒 提交于 2019-12-12 13:56:21
问题 I have a string which can contain a date(yyyy-MM-dd) or date and time (yyyy-MM-dd HH:mm:ss) in respective formats. I want to know which strings contains only date. DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(dateFormat.parse("2015-02-02")); System.out.println(dateFormat.parse("2015-02-02 23:23:23")); In above code, both the strings are parsed successfully, whereas the format is same for only first. 回答1: I would use the overload of parse which takes a