datetime-format

sqlite throwing a “String not recognized as a valid datetime”

拜拜、爱过 提交于 2019-11-27 14:47:23
问题 I am playing around with Sqlite and keep getting an error when trying to read back some test data. For example, I created a simple db with a single table and some columns and populated it with some test data as shown below. sqlite> .schema CREATE TABLE "shows"(id integer primary key asc autoincrement, showName TEXT, guest TEXT, dateAired date, dateWatched date); sqlite> select * from shows; 6|test show|test guest 1|2012.05.01|2012.07.10 7|test show|test guest 2|2012.05.02|2012.07.10 8|test

Convert DateTime to a specified Format

六眼飞鱼酱① 提交于 2019-11-27 14:22:54
I have this date format yy/MM/dd HH:mm:ss ex: 12/02/21 10:56:09 . The problem is, when i try to convert it to different format using this code: CDate("12/02/21 10:56:09").ToString("MMM. dd, yyyy HH:mm:ss") It displays Dec. 12, 2021 10:56:09 . How can i correctly format it to: Feb. 21, 2012 10:56:09 ? This format is returned when i check balance inquiry fro my SMS based application. Use DateTime.ParseExact , e.g.: DateTime.ParseExact("12/02/21 10:56:09", "yy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture ).ToString("MMM. dd, yyyy HH:mm:ss") Mitesh Vora Even easier way to convert Date: Convert

Set date 10 days in the future and format to dd/mm/yyyy (e.g. 21/08/2010)

試著忘記壹切 提交于 2019-11-27 13:31:19
I would really appreciate some help creating some JavaScript that will eventually be used in Selenium that automatically sets a date 10 days ahead from the current date and displays in the following format dd/mm/yyyy. I currently have the script below, but I'm not getting anywhere with it : var myDate=new Date(); myDate.now.format(myDate.setDate(myDate.getDate()+5),("dd/mm/yyyy"); Any help would be much appreciated. Here is an example of getting the future date... var targetDate = new Date(); targetDate.setDate(targetDate.getDate() + 10); // So you can see the date we have created alert

Convert String to java.util.Date

你说的曾经没有我的故事 提交于 2019-11-27 13:06:50
I am storing the dates in a SQLite database in this format: d-MMM-yyyy,HH:mm:ss aaa When I retrieve the date with that format I am get every thing fine except the hour. The hour is always 00 . Here is my output: String date--->29-Apr-2010,13:00:14 PM After convrting Date--->1272479414000--Thu Apr 29 00:00:14 GMT+05:30 2010 Here is the code: Date lScheduledDate = CalendarObj.getTime(); DateFormat formatter = new SimpleDateFormat("d-MMM-yyyy,HH:mm:ss aaa"); SomeClassObj.setTime(formatter.format(lScheduledDate)); String lNextDate = SomeClassObj.getTime(); DateFormat lFormatter = new

DateTime.ToString() format that can be used in a filename or extension?

荒凉一梦 提交于 2019-11-27 09:55:24
问题 I want to add a timestamp to filenames as files are created but most of the DateTime methods I've tried output something with spaces and slashes. For instance: Debug.WriteLine(DateTime.Now.ToString()); // <-- 9/19/2012 1:41:46 PM Debug.WriteLine(DateTime.Now.ToShortTimeString()); // <-- 1:41 PM Debug.WriteLine(DateTime.Now.ToShortDateString()); // <-- 9/19/2012 Debug.WriteLine(DateTime.Now.ToFileTime()); // <-- 129925501061462806 ToFileTime() works but is not exactly human-readable. How can I

Java Date changing format [duplicate]

无人久伴 提交于 2019-11-27 09:05:44
问题 This question already has answers here : java.util.Date format conversion yyyy-mm-dd to mm-dd-yyyy (6 answers) Closed 2 years ago . I am trying to change the format of Date objects, I am trying to do it in this way: for(Date date : dates){ DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); String formatterDate = formatter.format(date); Date d = formatter.parse(formatter.format(date)); } But this does not have any effect on the d object, it is still with the old format, can't really

Exception when trying to parse a LocalDateTime

放肆的年华 提交于 2019-11-27 08:27:52
问题 I am using the following timestamp format: yyyyMMddHHmmssSSS The following method works fine: public static String formatTimestamp(final Timestamp timestamp, final String format) { final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format); return timestamp.toLocalDateTime().format(formatter); } And, when I pass in a Timestamp with that format string, it returns, for example: 20170925142051591 I then require to map from that string to a Timestamp again, essentially the reverse

String-Date conversion with nanoseconds

余生长醉 提交于 2019-11-27 08:24:46
I've been struggling for a while with this piece of code for an Android app and I can't get the hang of it. I've read and tried every solution I found on stackoverflow and other places, but still no luck. What I want to do is have a function to convert a string like "17.08.2012 05:35:19:7600000" to a UTC date and a function that takes an UTC date and converts it to a string like that. String value = "17.08.2012 05:35:19:7600000"; DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss:SSSSSSS"); try { Date today = df.parse(value); System.out.println("Today = " + df.format(today) + " " +

Localized date format in Java

吃可爱长大的小学妹 提交于 2019-11-27 07:59:07
问题 I have a timestamp in millis and want to format it indicating day, month, year and the hour with minutes precission. I know I can specify the format like this: SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yy HH:mm"); String formatted = simpleDateFormat.format(900000) But I'd like the format to be localized with the user's locale. I've also tried DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); DATE_FORMAT.format(new Date()); But it

Laravel $q->where() between dates

青春壹個敷衍的年華 提交于 2019-11-27 07:33:18
I am trying to get my cron to only get Projects that are due to recur/renew in the next 7 days to send out reminder emails. I've just found out my logic doesn't quite work. I currently have the query: $projects = Project::where(function($q){ $q->where('recur_at', '>', date("Y-m-d H:i:s", time() - 604800)); $q->where('status', '<', 5); $q->where('recur_cancelled', '=', 0); }); However, I realized what I need to do is something like: Psudo SQL: SELECT * FROM projects WHERE recur_at > recur_at - '7 days' AND /* Other status + recurr_cancelled stuff) */ How would I do this in Laravel 4, and using