本文整理汇总了C#中System.DateTime.ToLongDateString方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToLongDateString方法的具体用法?C# DateTime.ToLongDateString怎么用?C# DateTime.ToLongDateString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToLongDateString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertDateToString
/// <summary>
/// �����ڶ���ת��Ϊ��ʽ�ַ���
/// </summary>
/// <param name="oDateTime">���ڶ���</param>
/// <param name="strFormat">
/// ��ʽ��
/// "SHORTDATE"===������
/// "LONGDATE"==������
/// ����====�Զ����ʽ
/// </param>
/// <returns>�����ַ���</returns>
public static string ConvertDateToString(DateTime oDateTime, string strFormat)
{
string strDate = "";
try
{
switch (strFormat.ToUpper())
{
case "SHORTDATE":
strDate = oDateTime.ToShortDateString();
break;
case "LONGDATE":
strDate = oDateTime.ToLongDateString();
break;
default:
strDate = oDateTime.ToString(strFormat);
break;
}
}
catch (Exception)
{
strDate = oDateTime.ToShortDateString();
}
return strDate;
}
示例2: checkDateTime
private static Boolean checkDateTime(DateTime time)
{
Boolean result = false;
String path = ApplicationData.Current.LocalFolder.Path + "/time.txt";
if (File.Exists(path)) {
TextReader reader = new StreamReader(path);
String date = reader.ReadLine();
reader.Close();
DateTime timeFile = DateTime.Parse(date);
int compared = timeFile.CompareTo(time);
if (compared > 0)
{
TextWriter tw = new StreamWriter(path);
tw.WriteLine(time.ToLongDateString() + " " + time.ToLongTimeString());
tw.Close();
result = true;
}
} else {
TextWriter tw = new StreamWriter(path);
tw.WriteLine(time.ToLongDateString() + " " + time.ToLongTimeString());
tw.Close();
}
return result;
}
示例3: setToDayOfYear
public void setToDayOfYear(int aDayOfYear) {
initLabels();
DateTime theDate = new DateTime( 2015, 12, 28 ).AddDays( aDayOfYear );
title.text = theDate.ToLongDateString().Substring(0,theDate.ToLongDateString().Length-5);
if(aDayOfYear==ChampionshipSeason.ACTIVE_SEASON.secondsPast) {
TweenColor.Begin(this.gameObject,0.25f,this.tint);
//this.GetComponent<UISprite>().color = this.tint;
} else {
TweenColor.Begin(this.gameObject,0.25f,this.original);
//this.GetComponent<UISprite>().color = ;
}
GTTeam myTeam = ChampionshipSeason.ACTIVE_SEASON.getUsersTeam();
TrackDatabaseRecord tdr = ChampionshipSeason.ACTIVE_SEASON.seasonForTeam(myTeam).eventOnDay(aDayOfYear);
UITexture t= this.GetComponentInChildren<UITexture>();
if(tdr!=null) {
Texture texture1 = (Texture) Resources.Load ("Race/Thumbnails/"+tdr.imagePrefabName);
if(t!=null)
t.mainTexture = texture1;
} else {
if(t!=null)
t.mainTexture = null;
tdr = ChampionshipSeason.ACTIVE_SEASON.seasonForTeam(myTeam).eventOnDay(aDayOfYear+7);
if(tdr!=null) {
title.text += "\n(One week till next race)";
}
RandomEvent specialEvent = ChampionshipSeason.ACTIVE_SEASON.seasonForTeam(myTeam).getRandomEventOnDay(aDayOfYear);
if(specialEvent!=null) {
Texture texture1 = (Texture) Resources.Load ("gambleicon");
if(t!=null) {
t.mainTexture = texture1;
}
}
}
if(myTeam.hasResearchCompletingOnDay(aDayOfYear)) {
GTCar car1 = myTeam.cars[0];
GTCar car2 = myTeam.cars[1];
GTDriver driver1 = myTeam.drivers[0];
GTDriver driver2 = myTeam.drivers[1];
string research = "";
if(car1.hasResearchCompletingOnDay(aDayOfYear)!=null) {
GTEquippedResearch researchBit = car1.hasResearchCompletingOnDay(aDayOfYear);
research = researchBit.researchRow._partname+" Completion for "+driver1.name+"\n";
}
if(car2.hasResearchCompletingOnDay(aDayOfYear)!=null) {
GTEquippedResearch researchBit = car2.hasResearchCompletingOnDay(aDayOfYear);
research += researchBit.researchRow._partname+" Completion for "+driver2.name;
}
this.researchText.text = research;
} else {
this.researchText.text = "";
}
}
示例4: FillMeMonth
public void FillMeMonth(DateTime date)
{
try
{
this.paymentsDS.Payments.Clear();
this.paymentsTableAdapter.Connection.ConnectionString = myForms.myConnectionString;
this.paymentsTableAdapter.FillByMonth(this.paymentsDS.Payments,date.ToLongDateString(),date.ToLongDateString());
this.paymentsBindingSource.DataMember = "Payments";
this.paymentsBindingSource.ResetBindings(false);
}
catch (Exception ex)
{
myForms.MsgBox(ex.Message);
}
}
示例5: EvidencijaTreningaIzvestaj
public EvidencijaTreningaIzvestaj(Nullable<int> clanId, DateTime from, DateTime to, List<Grupa> grupe)
{
this.clanId = clanId;
Title = "Dolazak na trening";
string subtitle;
if (from.Date == to.Date)
{
subtitle = from.ToLongDateString();
subtitle += " " + from.ToShortTimeString() + " - " + to.ToShortTimeString();
}
else
{
subtitle = from.ToShortDateString() + " " + from.ToShortTimeString();
subtitle += " - " + to.ToShortDateString() + " " + to.ToShortTimeString();
}
SubTitle = subtitle;
DocumentName = Title;
clanFont = new Font("Arial", 10, FontStyle.Bold);
itemFont = new Font("Courier New", 9);
Font itemsHeaderFont = null;
Font groupTitleFont = new Font("Courier New", 10, FontStyle.Bold);
lista = new EvidencijaTreningaLista(clanId, from, to, grupe, this, 1, 0f,
itemFont, itemsHeaderFont, groupTitleFont);
}
示例6: DisplayText
public void DisplayText(NetworkEvent ne)
{
this.m_Image = null;
DateTime time = new DateTime(ne.timeIndex);
this.infoLabel.Text = "";
this.appendText("Sender: " + ne.source);
this.appendText("Time: " + time.ToLongDateString() + " " + time.ToLongTimeString());
if (ne is NetworkChunkEvent) {
NetworkChunkEvent nce = ne as NetworkChunkEvent;
this.appendText("Category: Chunk");
this.appendText("Message Sequence: " + nce.chunk.MessageSequence);
this.appendText("Chunk Sequence: " + nce.chunk.ChunkSequence);
this.appendText("First Chunk Sequence of Message: " + nce.chunk.FirstChunkSequenceOfMessage);
this.appendText("Number of Chunks: " + nce.chunk.NumberOfChunksInMessage);
} else if (ne is NetworkMessageEvent) {
NetworkMessageEvent nme = ne as NetworkMessageEvent;
this.appendText("Category: Message");
this.displayMessageEventRecursive(nme.message);
} else if (ne is NetworkNACKMessageEvent) {
} else {
//Unknown
this.infoLabel.Text = "Unknown Type";
}
this.doubleBufferPanel.Invalidate();
}
示例7: CellTag
public IHtmlNode CellTag(DateTime currentDay, DateTime? selectedDate, string urlFormat, bool isOtherMonth)
{
IHtmlNode cell = new HtmlElement("td");
if (isOtherMonth)
{
cell.AddClass("t-other-month");
}
else if (selectedDate.HasValue && IsInRange(selectedDate.Value) && currentDay.Day == selectedDate.Value.Day)
{
cell.AddClass(UIPrimitives.SelectedState);
}
if (IsInRange(currentDay))
{
var href = GetUrl(currentDay, urlFormat);
IHtmlNode link = new HtmlElement("a")
.AddClass(UIPrimitives.Link + (href != "#" ? " t-action-link" : string.Empty))
.Attribute("href", href)
.Attribute("title", currentDay.ToLongDateString())
.Text(currentDay.Day.ToString());
cell.Children.Add(link);
}
else
{
cell.Html(" ");
}
return cell;
}
示例8: GetOper
// ָ��Ϊǰһ�����ֵ���룬x%���
public override ICollection<StockOper> GetOper(DateTime day, IAccount account)
{
IStockData prevStockProp = stockHistory.GetPrevDayStock(day);
if (prevStockProp == null)
{
Debug.WriteLine("StrategyPercent -- GetPrevDayStock ERROR: Cur Day: " + day.ToLongDateString());
return null;
}
ICollection<StockOper> opers = new List<StockOper>();
int stockCount = Transaction.GetCanBuyStockCount(account.BankRoll,
prevStockProp.MinPrice);
if (stockCount > 0)
{
StockOper oper = new StockOper(prevStockProp.MinPrice, stockCount, OperType.Buy);
opers.Add(oper);
}
if (stockHolder.HasStock())
{
double unitCost = stockHolder.UnitPrice;
if (unitCost > 0)
{
StockOper oper2 = new StockOper(unitCost * (1 + winPercent), stockHolder.StockCount(), OperType.Sell);
opers.Add(oper2);
}
}
return opers;
}
示例9: getEaster
public string getEaster(int year)
{
int offset;
int leap;
int day;
int temp1;
int temp2;
int total;
offset = year % 19;
leap = year % 4;
day = year % 7;
temp1 = (19 * offset + 24) % 30;
temp2 = (2 * leap + 4 + day + 6 * temp1 + 5) % 7;
total = (22 + temp1 + temp2);
if (total > 31)
{
month = 4;
day = total - 31;
}
else
{
month = 3;
day = total;
}
DateTime myDT = new DateTime(year, month, day);
return myDT.ToLongDateString();
}
示例10: InsertSensorData
public int InsertSensorData(
int sensorMetadataId,
int intermediateHwMetadataId,
string measuredData,
DateTime measuredAt,
DateTime polledAt,
int sensorType)
{
// using (SqlConnection connection = new SqlConnection(connectionStringb.ConnectionString))
using (SqlConnection connection = new SqlConnection(this.connectionString))
{
string queryString =
string.Format(
"INSERT INTO SensorData (SensorMetadataId, IntermediateHwMedadataId, MeasuredData, MeasuredAt, SendAt, PolledAt, UpdatedAt, CreatedAt, SensorType) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');",
sensorMetadataId,
intermediateHwMetadataId,
measuredData,
measuredAt.ToLongDateString() + " " + measuredAt.ToLongTimeString(),
measuredAt.ToLongDateString() + " " + measuredAt.ToLongTimeString(),
polledAt.ToLongDateString() + " " + polledAt.ToLongTimeString(),
measuredAt.ToLongDateString() + " " + measuredAt.ToLongTimeString(),
measuredAt.ToLongDateString() + " " + measuredAt.ToLongTimeString(),
sensorType);
SqlCommand command = new SqlCommand(queryString, connection);
return ExecuteSQLCommand(command);
}
}
示例11: NRVFile
public NRVFile(string ERName, string Door, string CardType, DateTime StartTime, string NVRFile, string VideoRecord)
{
InitializeComponent();
txt_ERName.Text = ERName;
txt_Door.Text = Door;
txt_StartTime.Text = StartTime.ToLongDateString() + " " + StartTime.ToLongTimeString();
txt_EventName.Text = CardType;
nvrFile = NVRFile;
string showNVRFile= "/VideoRecord/" + nvrFile.Trim();
//media.Source = new Uri("http://192.192.85.64/secure/ClientBin" + showNVRFile,UriKind.Absolute);
media.Source = new Uri(VideoRecord + showNVRFile, UriKind.Absolute);
double totalSeconds = media.Position.TotalSeconds; // 获取当前位置秒数
double nowTotalSeconds = media.NaturalDuration.TimeSpan.TotalSeconds; //获取文件总播放秒数
nowTime.Text = totalSeconds.ToString();
totalTime.Text = (Math.Round(nowTotalSeconds, 0)).ToString();
//WebClient wc = new WebClient();
//wc.OpenReadCompleted +=(s,a)=>
// {
// media.SetSource(a.Result as Stream);
// };
//wc.OpenReadAsync(new Uri("http://192.192.85.64/secure/ClientBin" + showNVRFile,UriKind.Absolute));
}
示例12: GetOper
// ����㷨��ָ��Ϊǰһ�����ֵ���룬���ֵ���
public override ICollection<StockOper> GetOper(DateTime day, IAccount account)
{
IStockData prevStock = stockHistory.GetPrevDayStock(day);
if (prevStock == null)
{
Debug.WriteLine("StrategyMinMax -- GetPrevDayStock ERROR: Cur Day: " + day.ToLongDateString());
//Debug.Assert(false);
return null;
}
ICollection<StockOper> opers = new List<StockOper>();
int stockCount = Transaction.GetCanBuyStockCount(account.BankRoll,
prevStock.MinPrice);
if (stockCount > 0)
{
StockOper oper = new StockOper(prevStock.MinPrice, stockCount, OperType.Buy);
opers.Add(oper);
}
if (stockHolder.HasStock())
{
StockOper oper2 = new StockOper(prevStock.MaxPrice, stockHolder.StockCount(), OperType.Sell);
opers.Add(oper2);
}
return opers;
}
示例13: EnumerateComputersAndLastLogonTimeStamp
public static String[,] EnumerateComputersAndLastLogonTimeStamp()
{
List<SearchResult> computerList = new List<SearchResult>(EnumerateComputers());
// List<DateTime> lastLogonTimeStampList = new List<DateTime>();
String[,] computerAndTimeStamp = new String[computerList.Count, computerList.Count];
ResultPropertyCollection myResultPropColl;
int i = 0;
foreach (SearchResult computer in computerList)
{
long lastLogonTimeStamp;
DateTime dateTime = new DateTime();
myResultPropColl = computer.Properties;
if (computer.Properties.Contains("lastlogontimestamp"))
{
lastLogonTimeStamp = (long)(myResultPropColl["lastlogontimestamp"][0]);
dateTime = DateTime.FromFileTime(lastLogonTimeStamp);
//lastLogonTimeStampList.Add(dateTime);
computerAndTimeStamp[i, 0] = computer.GetDirectoryEntry().Name.Substring(3).ToUpper();
computerAndTimeStamp[i, 1] = dateTime.ToLongDateString();
}
else
{
computerAndTimeStamp[i, 0] = computer.GetDirectoryEntry().Name.Substring(3).ToUpper();
computerAndTimeStamp[i, 1] = "No timestamp";
}
i++;
}
return computerAndTimeStamp;
/* foreach (string myKey in myResultPropColl.PropertyNames)
{
properties += myKey + " = ";
foreach (Object myCollection in myResultPropColl[myKey])
{
properties += myCollection + "\n";
}
}
*
MessageBox.Show(properties);*/
//System.DateTime dateTime = new System.DateTime(1601, 1, 1, 0, 0, 0, 0);
// System.DateTime dateTime2 = System.DateTime.FromFileTime(Convert.ToInt64(myResultPropColl["lastlogontimestamp"].ToString()));
// Add the number of seconds in UNIX timestamp to be converted.
// ulong timestamp = Convert.();
//dateTime = dateTime.AddMilliseconds(timestamp);
// The dateTime now contains the right date/time so to format the string,
// use the standard formatting methods of the DateTime object.
//string printDate = dateTime2.ToShortDateString() +" "+ dateTime2.ToShortTimeString();
// MessageBox.Show(dateTime2.ToString());
}
示例14: OnDateSet
public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
// Note: monthOfYear is a value between 0 and 11, not 1 and 12!
DateTime selectedDate = new DateTime(year, monthOfYear + 1, dayOfMonth);
Log.Debug(TAG, selectedDate.ToLongDateString());
_dateSelectedHandler(selectedDate);
}
示例15: ComboBoxSelectDateTime_DropDown
private void ComboBoxSelectDateTime_DropDown( object sender, EventArgs eventArgs )
{
this.axDatePickerSelectDataTime.Left = this.ComboBoxSelectDateTime.Left;
this.axDatePickerSelectDataTime.Top = this.ComboBoxSelectDateTime.Top + ComboBoxSelectDateTime.Height + 1;
this.axDatePickerSelectDataTime.EnsureVisible( DateTime.Now - TimeSpan.FromDays( 90.0 ) );
if ( this.axDatePickerSelectDataTime.ShowModal( 2, 2 ) == true )
{
int nCount = this.axDatePickerSelectDataTime.Selection.BlocksCount;
if ( nCount > 0 )
{
if ( this.axDatePickerSelectDataTime.Selection[nCount - 1].DateEnd > DateTime.Now )
m_DateEnd = DateTime.Now;
else
m_DateEnd = this.axDatePickerSelectDataTime.Selection[nCount - 1].DateEnd;
if ( this.axDatePickerSelectDataTime.Selection[0].DateBegin > ( m_DateEnd - TimeSpan.FromDays( 3.0 ) ) )
m_DateBegin = m_DateEnd - TimeSpan.FromDays( 2.0 );
else
m_DateBegin = this.axDatePickerSelectDataTime.Selection[0].DateBegin;
m_DateSelection = m_DateEnd;
this.ComboBoxSelectDateTime.Text = m_DateSelection.ToLongDateString();
this.NumericUpDownKLine.Value = ( m_DateEnd - m_DateBegin ).Days + 1;
}
}
KLineU50ConfigB.PostMessage( this.ComboBoxSelectDateTime.Handle.ToInt32(), CB_SHOWDROPDOWN, 0, 0 );
}