w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I get SQL Server to use User Locale for Date format for a Query?
You can set the date format using SET DATEFORMAT XXX SET DATEFORMAT DMY SELECT * from DateFieldTest where DateField >= '24/04/2013' http://msdn.microsoft.com/fr-fr/library/ms189491.aspx

Categories : Sql Server

What is the best practise to maintain authenticated user details in an ASP.NET Intranet MVC application
You can still use session state in MVC, but it is not advisable. MVC as a pattern respects the statelessness of HTTP. One alternative is to use Cache which only stores information in memory. Here is a SO question with more information: Why would ASP.NET MVC use session state? Here is one more: Is it a good practice to avoid using Session State in ASP.NET MVC? If yes, why and how?

Categories : Asp Net Mvc

convert from datetime to another locale datetime in java
if both have correct time and time zone, Date in milliseconds will be same for both server and client, no matter in what time zone they are . Send the date from client in milliseconds and accept it on serverside in a java.sql.Date(long) constructor. You mentioned javascript in tags. So Date can be sent through javascript using new Date(); and can be accepted by server using new java.sql.Date(client_date); In milliseconds, the client time would be converted to appropriate server time. If client time is not properly set, for that, you can use the time difference in milliseconds like - long time_difference= new Date()-new Date(client_date); long server_time_of_execution=new Date(Client_date_to_execute).getTime()+time_difference;

Categories : Java

Dealing with DateTime format for international application
Outputting as an ISO string is the right way to go. It will probably benefit you to use the JavaScript Date's toISOString. As not every browser supports it, you will want to supply it for browsers that do not: if ( !Date.prototype.toISOString ) { ( function() { function pad(number) { var r = String(number); if ( r.length === 1 ) { r = '0' + r; } return r; } Date.prototype.toISOString = function() { return this.getUTCFullYear() + '-' + pad( this.getUTCMonth() + 1 ) + '-' + pad( this.getUTCDate() ) + 'T' + pad( this.getUTCHours() ) + ':' + pad( this.getUTCMinutes() ) + ':' + pad( this.getUTCSeconds() ) + '.' + String( (this.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 ) + 'Z

Categories : Javascript

Identify User with common identifer for windows azure mobile services & MVC web application
It doesnt really answer how to get around the issues highlighted above. I imagine using the same type of authentication in my MVC application would have got around this, but then I would have to have found a way to get the email address for a google account. Then I would have had to consider how to handle other authentication providers which would have brought other issues. I found other issues with windows azure mobile services which meant it just wasnt for me Does not seem to be a way of accessing data from a different database namespace with mobile services I was re-writing business logic in the mobile service that I already had in my MVC application, which I had unit tested, with entity framework etc It seems simple and straight forward if you follow the examples of mobile service

Categories : Asp Net Mvc

Covert c# datetime format to java datetime format
Your format string doesn't match the input date string : // 2013-07-03T19:16:02.3694 <-- date string static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); You need to first parse the date string using the SimpleDateFormat with pattern yyyy-MM-dd'T'HH:mm:ss.SSSSSS and then you can format the Date object with dd-MM-YYYY pattern.Remember MM is for months , mm stands for minutes. String formattedDate = new SimpleDateFormat("dd-MM-YYYY").format( new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS") .parse(reportItem.getString("AddedTime")));

Categories : C#

Get datetime mask for a given locale
Use the django.utils.formats module: from django.utils import formats date_format = get_format('DATE_FORMAT') get_format(format_type, lang=None, use_l10n=None) returns the current format used; set use_l10n to force localisation to be applied (defaults to your settings.USE_L10N flag), or use the lang argument to pick a specific language: >>> from django.utils import formats >>> formats.get_format('DATE_FORMAT') 'N j, Y' >>> formats.get_format('DATE_FORMAT', lang='de') 'j. F Y' See the available date format strings to see what the various strings mean. Alternatively, use the javascript catalog view, which includes JavaScript get_format() function. Either way, the Django format is not a JS-recognized format. You have two options: Use this Django snippet to

Categories : Python

How can I use make to maintain a common C++ header include directory?
Alternatively, is there a better way to make my header files available to other components in the same project? There are two obvious and simple ways: keep all the headers in the include dir in the first place set up CPPFLAGS for each component to tell it where to find its dependencies. I'd recommend the former approach for small, tightly-coupled projects. The second approach is better for really componentized systems, as it forces you to think about the internal dependencies in your project.

Categories : C++

PHP - Codeigniter set views datetime to locale
Depending how you store the timezone preference, you could use date_default_timezone_set(). For example: date_default_timezone_set('America/New_York'); Note: I'm not familiar with CodeIgnitor, but so long as you set this in a bootstrap or config script, that is before you call date(), this will automatically display all dates in the set locale.

Categories : PHP

Given a dateTime object in C#, show date according to computer locale?
DateTime.ToString() without parameters actually uses the current culture. So the output of .ToString() will be different on multiple machines, depending on their culture.

Categories : C#

format string in datetime c# to insert in MYSQL datetime column
Your line: string time = Convert.ToDateTime("10-10-2014 15:00:00"); Shouldn't compile. I can only guess that you don't have DateTime as type of your column in SQL Server, you should modify it to keep DateTime and then pass a DateTime type object, not a string.

Categories : C#

SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates
To remove the warning just add Locale.getDefault() as the second argument while instantiating the date format object. Eg. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.getDefault());

Categories : Android

Sql query for CONVERT datetime to a different datetime Format in SQL 2005?
http://msdn.microsoft.com/en-us/library/ms187928.aspx check out see Microsoft's explanation on date formats the one you're looking for is 20 or 120 BTW, you should supply with varchar with a number like this varchar(10)

Categories : SQL

Adding date or time in datetime format to another datetime
*This is a method using DateTime:* $begin = new DateTime($start); $finish = new DateTime($end); $difference = $finish->format('U') - $begin->format('U'); // working version $minutesDiff = round(($difference/60), 0); $finalDate = new DateTime(); $finalDate->modify(sprintf('+%s minutes', $minutesDiff)); edit added missing bracket edit2 version without ->diff() method

Categories : PHP

How to store user's preferred currency format in Rails application?
I think you've made it better to use individual’s preferences/settings instead of app settings. But there is still a concern in your new arrangement. What if an user want to change his currency, say from Euro to Canada Dollar? This will be not so easy in your app because his current amount is in Euro. You need to convert this amount into Can Dollar and take currency rate into consideration which adds complexity. And the amount will not be consistent. For example, if he want to change back to Euro after a few days, it's very likely he will meet a new Euro amount. My suggestions: Use a consistent amount and currency for everything. Say the price is always US$ 19. The user can have his own currency, of course, but it will be converted from the base amount which is US Dollar. Use separ

Categories : Ruby On Rails

How to convert SCORM 2004 session_time format to a usable datetime format in SQL
Just worked out a solution for me. This would need to be put inside a SQL function for me and I would need to finish off the last bit where I decide what format I want. I am only updating around 900 rows and it is a 1 off update so performance isn't an issue. DECLARE @session_time varchar(200) = 'P50Y2M3DT4H5M6S' DECLARE @date varchar(100) = '' DECLARE @time varchar(100) = '' DECLARE @year varchar(20) = '0' DECLARE @month varchar(20) = '0' DECLARE @day varchar(20) = '0' DECLARE @hour varchar(20) = '0' DECLARE @minute varchar(20) = '0' DECLARE @second varchar(20) = '0' -- Remove the P SET @session_time = SUBSTRING(@session_time, 2, LEN(@session_time)-1) -- If we have a T IF PATINDEX('%T%',@session_time) > 0 BEGIN SET @date = SUBSTRING(@session_time, 0, PATINDEX('%T%',@session_

Categories : PHP

asp.net DetailView datetime field format doesn't match the SQL Server format
Check Your PC Date format and enter date of same format in due date if you enters the date time dynamically then use like this DateTime.Now.ToString(yyyy-MM-dd) here yyyy-MM-dd is my date format enter yours format in this and this is for current date you can use it for the date you desired

Categories : C#

Changing an application's locale without changing the Windows locale
If new threads don't use the same locale you can start them like this: Thread theNewThread = new Thread(() => { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); //Make something else }); theNewThread.Start(); Or in other way; public static void Start(this Thread thread, CultureInfo cu) { //Set the CU here.. thread.Start(); } Didn't tried this but I gess it could work

Categories : C#

Convert Datetime format to varchar format style workaround
Well you can convert both Dates in any format before you compare the two just use any of these: run this and you can select from them, make sure to convert both dates before Comparing Select convert(varchar, GetDate(), 100) as '100 Conversion', convert(varchar, GetDate(), 101) as '101 Conversion', convert(varchar, GetDate(), 102) as '102 Conversion', convert(varchar, GetDate(), 103) as '103 Conversion', convert(varchar, GetDate(), 104) as '104 Conversion', convert(varchar, GetDate(), 105) as '105 Conversion', convert(varchar, GetDate(), 106) as '106 Conversion', convert(varchar, GetDate(), 107) as '107 Conversion', convert(varchar, GetDate(), 108) as '108 Conversion', convert(varchar, GetDate(), 109) as '109 C

Categories : SQL

DateTime to XML format but keep the datatype as datetime
The dateTime object holds the date and time in a way that is independent of any formatting. The output format is chosen when you convert the value to a string. If it comes out as dd:mm:yyyy, that's because it's defaulting to the format used by the country/language configured for your machine. So the answer is, if you want the ISO format (which you refer to as XML format), then the time to request this is at the time you output the dateTime as XML; it's not a property of the date/time value itself.

Categories : C#

How do I format a timestamp field from database to dutch locale?
Try this: setlocale(LC_ALL, 'nl_NL'); echo strftime('%A %e %B %Y', strtotime($vac->geplaatstop)); The function mktime()'s arguments are different time elements, see the documentation here: mktime() - http://php.net/manual/en/function.mktime.php

Categories : PHP

Inconsistent date time format for German locale
I can suggest a workaround: SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.GERMAN); DateFormatSymbols dfs = df.getDateFormatSymbols(); String[] swd = {"", "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"}; dfs.setShortWeekdays(swd); df.setDateFormatSymbols(dfs); now it will format dates into Mi, 24 Jul 2013 12:33:12 +0200 in both standard Java and Android

Categories : Java

JavaScript Date format conversion using locale information
use toLocaleDateString var date = new Date(Date.UTC(2012, 11, 11, 3, 0, 0)); date.toLocaleDateString('en-GB'); // "11/12/2012" date.toLocaleDateString('en-US'); // "12/11/2012"

Categories : Javascript

How to handle SQL DateTime conversion from XML input in a common way
I found a way to do this but I really don't like the process. I created a simple scalar function in SQL that takes in the date as a string and restricts it to 23 characters. Then a CONVERT to datetime is used if the string is not null or empty. Then everywhere I have a date coming in I wrap this function around it. If someone has a better option let me know. It works but, seems like a hack :( Example: SELECT [dbo].GetFormattedDate('2013-07-01T14:27:00.434') ,[dbo].GetFormattedDate('') ,[dbo].GetFormattedDate(NULL) ,[dbo].GetFormattedDate('2013-07-01T14:27:00.434Z') ,[dbo].GetFormattedDate('2013-07-01T14:27:00.434445Z') ,[dbo].GetFormattedDate('2013-07-01') Function Code: CREATE FUNCTION [dbo].[GetFormattedDate] ( @p_DateString varchar(23) ) RETURNS datetime AS BEGIN

Categories : SQL

Javascript datetime format in database format
dateToString : function (unformatted) { if (!unformatted) { return null; } var year = unformatted.getFullYear(); var month = unformatted.getMonth() + 1; var day = unformatted.getDate(); if (month < 10) { month = '0' + month; } if (day < 10) { day = '0' + day; } return [year, month, day].join('-'); } feel free to add time formatting

Categories : Javascript

Get custom datetime format from standard format
Here's some code do get the patterns: var c = new CultureInfo("fr-FR"); Console.WriteLine(c.DateTimeFormat.LongDatePattern); Console.WriteLine(c.DateTimeFormat.ShortDatePattern); Console.WriteLine(c.DateTimeFormat.FullDateTimePattern); The result from a console app is the following dddd d MMMM yyyy dd/MM/yyyy dddd d MMMM yyyy HH:mm:ss

Categories : C#

how to change date format of datetime format in php
I'd certainly hope that date values aren't actually stored in a textual format at all, any more than numbers are. It's a bit like asking the database to store numbers as hex instead of decimal. You should separate the inherent values within the data from the textual format applied to them when you present them. Normally I'd recommend formatting the data at the client side instead (which typically has more user context) but you can specify a format in the SELECT statement as well: SELECT DATE_FORMAT(StartDate, '%d-%m-%y') FROM SomeTable Likewise when inserting or updating data, I would try to use parameterized SQL so that you don't specify dates as text at all - normally the client library should be able to pass the data on to the database in a native binary format. In general, you sho

Categories : PHP

Can a renaming on an iOS application be done in one locale only?
Yes the CFBundleDisplayName and CFBundleName are localizable. You need to add your localizations in an InfoPlist.strings file and add specific localizations there.

Categories : IOS

how get user locale in jsp page when he visit website and display page in user language
Write an HttpFilter to handle this and map it in web.xml. if(request.getParameter("language")==null) { String userLocale = request.getHeader("Accept-Language"); Locale locale = request.getLocale(); if(req.getRequestUrl().contains("?")) { response.sendRedirect(req.getRequestUrl()+"&language="_locale.getLanguage()); } else { response.sendRedirect(req.getRequestUrl()+"?language="_locale.getLanguage()); } }

Categories : Java

Change Locale in MVC application on click
Setting the culture is only valid until the thread terminates, which happens after all page processing has finished. In this case, after you issue the redirect the server will send the Location HTTP header to the new address and close the response. The browser will then initiate a new request to the new location and the value you set in Thread.CurrentThread.CurrentCulture will reset to the default one. You have to persist the language selection (session, cookie...) and then apply it at start of your page logic.

Categories : Asp Net Mvc

Detect the user's locale automatically
There are at least two ways, but both of them don't gave you 100% guarantee to detect locale and detect it right. The first is to use $_SERVER['HTTP_ACCEPT_LANGUAGE'] variable. It's gotten via HTTP Headers and can even doesn't exist. The second is to use 3rd-side services to detect country by IP address and then compare country name to some local table of countries and their locales. For example: http://api.hostip.info/get_html.php?ip=127.0.0.1 For more information and comments look at this question: Simplest way to detect client locale in PHP And the final point is to integrate locale detection into the symfony2 project. This is the simplest part. You just need to use kernel.request event listner. Everything is perfectly explained (with examples) here: Symfony 2.1 set locale

Categories : Symfony2

User locale does not work at first request
I am not sure if this will work. But when user is logged in locale will be set in his/her session. you can do something like this in your listener: $request = $event->getRequest(); $session = $request->getSession(); $locale = $session->get('_locale'); if (!empty($locale)) { $request->setLocale($locale); } and on link where user will select locale you can create some action public function localeAction($locale) { $this->get('session')->set('_locale', $locale); return $this->redirect($this->generateUrl('route')); }

Categories : Symfony2

How accurate is the user locale on Android?
As far as I know, the Locale.getDefault() depends on the language you select in Settings->Language & Input->Language Setting only. If you switch it, the Locale.getDefault() switches, too!

Categories : Android

How do I save user's locale settings (in app)?
If the answer is Shared Preferences, then how? I've only used shared preferences to store strings. Yes, answer is SharedPreferences and you can use it to store Strings, just like you did before. Just make it store "en" or "sl" and then String enOrSlReadFromSharedPrefs = readSharedPrefsJustLikeYouDidBefore(); Locale locale = new Locale(enOrSlReadFromSharedPrefs); Locale.setDefault(locale); Configuration configSlo = new Configuration(); configSlo.locale = localeSlo; getBaseContext().getResources().updateConfiguration(configSlo, getBaseContext().getResources().getDisplayMetrics()); Intent intent = new Intent(NastavitveJezika.this, MainActivity.class); finish(); startActivity(intent);

Categories : Java

IIS 7 Classic Asp application Regional and Locale Cached?
Have you got localization set in your ASP page? It could be that your browser is using that to determine what date format should be shown. We tend to get dates in the database in the normal format and then convert using FormatDateTime to get around it. Hope that helps.

Categories : Iis

How to maintain a centralized Object across the application
Well the singleton design pattern would work - but isn't terribly clean; you end up with global static state which is hard to keep track of and hard to test. It's often considered an anti-pattern these days. There are a very few cases where it still makes sense, but I try to avoid it. A better approach would be to use dependency injection: make each class which needs one of these objects declare a constructor parameter of that type (or possibly have a settable property). Each class shouldn't care too much about how shared or otherwise the object is (beyond being aware that it can be shared). Then it's up to the code which initializes the application to decide which objects should be shared. There are various dependency injection frameworks available for Java, including Guice and Spring.

Categories : Java

How to maintain a unique timezone across web application
My suggestion is to set the timezone in the initialization script which creates the java process using the argument -Duser.timezone=NAME where NAME you can find in the list below: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones Note1: Unfortunately, the developer can create some objects like Calendar using a different TimeZone. For those cases you can use Java Security Polices (it will be hard to setup for a application server). But I think just configuring that is pretty enough. Note2 : By default the JVM collects the timezone from the user environment.

Categories : Java

Prompt user to enter path when application starts very first time. Run or stop application depending upon user's action (OK or Cancel)
Application.Exit() will exits the message loop only which is the loop after you call Application.Run .. If you want to exit from whole application- try Environment.Exit(0) It would just kill the process.

Categories : C#

Changing of Application Locale does not take full effect in android?
try restarting your activity as suggested by other answers, check Ben's answer How do I restart an Android Activity public void reload() { Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); }

Categories : Android

Localization testing on Android - Change Application or System locale
As far as I could notice, changing the application or the system Locale is not different with a side note that one would have to refresh the views. I've wrote a post about my experience with Multi-Languages... leave your comments at the bottom.

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.