date-format

Convert string variable to date

霸气de小男生 提交于 2019-12-11 07:19:58
问题 I need to convert a string variable to a date variable in a VBA macro, to process the date to get the mMonth and year in order to name the worksheet Call GetMonthandYear(MonthYear, FileDate) ActiveSheet.Name = MonthYear I looking to create a method called GetMonthandYear. FileDate is a String in a date format, dd.MM.yyyy HH-mm-ss . If I can change the variable to a date, I can change the format to MMMM/yyyy and then use ToString , I think, and assign it to MonthYear . Is there a way to change

How to change date time format on a localized website?

喜你入骨 提交于 2019-12-11 05:43:01
问题 I have a localized website for different languages Users can select which language to use in a profile and this will be applied beforePageLoad using context.setLocalString("en") "en" is default to en-US i believe so the dates on the website is displayed in the US format so I learned that I can use instead. context.setLocale(new Locale("en","gb")) the problem with setLocal is that is does not update the HTML lang="en" attribute so event though the dates are correct after using setLocal the

How to set date format in input of ng bootstrap

我们两清 提交于 2019-12-11 05:25:05
问题 I am using ng bootstrap datepicker. I want to set date format in input tag. This is my html code <input (click)="d.toggle()" type="text" [formControl]="updateEventForm.controls['live_date']" value="{{dispalyLiveDate | date: 'd/M/yy'}}" ngbDatepicker #d="ngbDatepicker"> Here {{dispalyLiveDate | date: 'd/M/yy'}} is my default value, when select date then date format is convert to yyyy-M-dd , i want this date format same as d/M/yy I had read document and find method format(date: NgbDateStruct)

How use Bulk insert csv to sql server with datetime format correct?

ぐ巨炮叔叔 提交于 2019-12-11 04:46:26
问题 i want use bulk insert file csv insert to SQL Server 2012 . same column have datetime but use bulk insert datetime format not work and i not use SSIS . Example Create Table CREATE TABLE [dbo].[scanindex_test]( [request_no] [varchar](13) NOT NULL, [request_date] [datetime] NULL, [id_card] [varchar](20) NULL, [firstname] [varchar](100) NULL, [surname] [varchar](100) NULL ) Query Sql Server 2012: declare @path varchar(255), @sql varchar(5000) SET @path = 'C:\Test\TESTFILE.csv' set @sql = 'BULK

How to use jQuery UI DatePicker and MVC 4 with custom format (dd.MM.yyyy)

杀马特。学长 韩版系。学妹 提交于 2019-12-11 04:22:49
问题 Let's say you want to use the datepicker with the custom Romanian format: dd.MM.yyyy How can you do this without encountering jquery validation problems and misinterpreting of the date time after a postback ? 回答1: First of all include datepicker-ro.js after jquery-ui.js. After that set the format in the model like this: public class ProductionCalculationReportModel { [DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)] public DateTime?

ParseException - Can't figure out the right pattern

会有一股神秘感。 提交于 2019-12-11 03:18:46
问题 I have the following string: dateToParse = "Fri May 16 23:59:59 BRT 2014" , and want to parse it using DateFormat: DateFormat dateFormat = new SimpleDateFormat(pattern, Locale.getDefault()); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo")); cal.setTime(dateFormat.parse(dateToParse)); right now I'm trying it with pattern = "EEE MMM dd HH:mm:ss z yyyy" , but get this exception: java.text.ParseException: Unparseable date: "Fri May 16 23:59:59 BRT 2014" (at offset 0)

Android parseException unparseable date in specific devices?

徘徊边缘 提交于 2019-12-11 02:04:02
问题 In my android App I am converting a string to a date using the following method public Date convertToDate(String date) { //(input date format "Feb 18, 2013 01:32 AM") DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); try { Date dateObj = dateFormat.parse(date); return dateObj; } catch (ParseException e) { e.printStackTrace(); } catch (Exception e) { Log.d("Utility", e.getMessage()); } return null; } It works fine in most of the mobile but for some

Parsing Java String to date

大兔子大兔子 提交于 2019-12-11 02:02:21
问题 log(2 different dates): START TIME BEFORE PARSE: 06/27/2012 09:00 START TIME AFTER PARSE : Thu Mar 06 09:00:00 EET 2014 START TIME BEFORE PARSE: 07/06/2012 09:00 START TIME AFTER PARSE : Thu Jun 07 09:00:00 EEST 2012 code : DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm"); Date date = sdf.parse(time); System.out.println("TIME BEFORE PARSE: " + time); System.out.println("TIME AFTER PARSE : " + date); Why does it mess up the year? How to get it to work? 回答1: Because you inverted the

Getting the correct GMT format using DateFormat Object

六眼飞鱼酱① 提交于 2019-12-11 01:38:39
问题 If i have a File object how can i get the lastModified() date of this file in this GMT format: Mon, 23 Jun 2011 17:40:23 GMT . For example, when i call the java method lastModified() on a file and use a DateFormat object to getDateTimeInstance(DateFormat.Long, DateFormat.Long) and also set the TimeZone to GMT, the file date displays in different format: File fileE = new File("/Some/Path"); Date fileDate = new Date (fileE.lastModified()); DateFormat dateFormat = DateFormat.getDateTimeInstance

Java, converting Date to String and back produced wrong Date

为君一笑 提交于 2019-12-10 20:37:30
问题 I am trying to convert a Date to String and then back again to Date . However I found out that the final date is different from the original date, what gives? //1975-06-20 Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 1975); cal.set(Calendar.MONTH, 5); cal.set(Calendar.DAY_OF_MONTH, 20); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); System.out.println(cal); Date originalDate = cal.getTime(); System.out.println("Date 1: " + originalDate