Wednesday, June 24, 2009

ShortDatePattern with MMM

I wanted date printed with the given culture format but to print month name instrad of month number like Jan instead of 01 in en-us, I tried this with few combination and DateTimeFormat along with RegEx came into rescue. here is the code.

DateTime date = DateTime.Today; // Take a date to display in given format.
CultureInfo culture = CultureInfo.GetCultureInfo("en-us"); // get a random calture.
string datePattern = culture.DateTimeFormat.ShortDatePattern; // get short date format

datePattern = Regex.Replace(datePattern, "(?i)[m]+", "MMM"); // replace Month natation for MMM to get 3 char long month name
Console.WriteLine(date.ToString(datePattern,culture)); // print date in given format

datePattern = Regex.Replace(datePattern, "(?i)[m]+", "MMMM"); // replace Month natation for MMMM to get full month name.
Console.WriteLine(date.ToString(datePattern, culture));


Cheers!!!
Pradeep

Wednesday, June 10, 2009

what a present surprise Hashtable and pradeep

While searching for something on google, to looked my post i ranked 1st on the google search. try
hashtable + c# in google or (click here). I feel now i should devote time to develop, teaching and writing skills :)


-- pradeep

Saturday, May 02, 2009

Who am i ?

I am not talking about movie of Jaki Chain with the same name,

Who am i?
Why am i here?
and what will happen to me after my death?
what is was before taking birth on earth ?

who can answer these queries, i am not able to find the solution.

--pradeep

Tuesday, May 20, 2008

do not forget to Remove DataRowFilter value

If you are playing with datatable`s DefaultView view then don`t forget to change it to default mode by setting RowFilter property of DefaultView to string.Empty, otherwise you may get in to trouble.
Same happened with my one of colleague, and after 2 days debugging she came to me.

== here is full code

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DatatableTest
{
public class DataTableOperationWrapper
{
DataTable dtTable;

public bool ConstructDataTableAndFillData()
{
if (dtTable == null)
{
CreateTable();
}
else
{
dtTable.Rows.Clear();
dtTable.AcceptChanges();
}

DataRow dr = dtTable.NewRow();

for (int i = 0; i <>
{
dr["Name"] = "PersonName_" + i.ToString();
dr["Age"] = i; dtTable.Rows.Add(dr);
dr = dtTable.NewRow();
}

dtTable.AcceptChanges();
return true;
}

private void CreateTable()
{
dtTable = new DataTable();
dtTable.Columns.Add("Name", typeof(string));
dtTable.Columns.Add("Age", typeof(int));
}

public void ApplyDataViewRowFilter(string fileterCondition)
{
if (dtTable == null)
{
ConstructDataTableAndFillData();
}
dtTable.DefaultView.RowFilter = fileterCondition;
}
public DataTable GetResult()
{
if (dtTable == null)
{
new ApplicationException("DataTable is null");
}
return dtTable;
}
///


/// Remove the filters applied as DataRowFilter condition and get all the data from datatable.
///

public void RemoveDataViewRowFilter()
{
if (dtTable == null)
{
new ApplicationException("DataTable is null");
}
dtTable.DefaultView.RowFilter = string.Empty;
}
}
}

== till here

i just tried to set RowFilter value to string.Empty and it worked.
(Don`t get into design of class mentioned above.)

Thanks
Pradeep

Saturday, March 01, 2008

World`s 3rd and 4th most poluted cities are in India

I just shocked, when i come to know India houses world`s 2 most polluted cities
these are Vapi in Gujrat 4th Rank
and Sukinda in Orissa 3rd Rank

here is location details http://www.mibazaar.com/pollutedcities.html
What is conclustion : We have to ask people and government to look into the matter seriously, otherwise surrounding areas mey get affected.

Thanks for your precious time...
Pradeep Tiwari
same post could be found at
http://happyrepublicdayindia.blogspot.com/

Thursday, February 28, 2008

Health - Important Tips

Answer the phone by LEFT ear.
Do not drink coffee TWICE a day.
Do not take pills with COOL water.
Do not have HUGE meals after 5pm.
Reduce the amount of OILY food you consume.
Drink more WATER in the morning, less at night.
Keep your distance from hand phone CHARGERS.
Do not use headphones/earphone for LONG period of time.
Best sleeping time is from 10pm at night to 6am in the morning.
Do not lie down immediately after taking medicine before sleeping.
When battery is down to the LAST grid/bar, do not answer the phone as the radiation is 1000 times.
Forward this to those whom you CARE about!



---Thanks and care
Pradeep

Tuesday, February 19, 2008

Few Products which i like

Here are few products which i like, try then for your need too....

1. For international calling (PC to phone call) As this is the time people make calls without boundaries for things like H1b , friends and others, here is low cast calling solution


Save on long distance!


2. Now a days, we see very exciting and full featured hand held devices from China, at least those are very much popular in India now a days, you can shop them using this like and order for a bulk if you are ruing a business

Hottest selling products include digital photo frames, MP4 players, and computer accessories.


Buy Quality China Products from Our B2B Store


Thanks
Pradeep