Neue Datum-Konvertierungsfunktion
This commit is contained in:
parent
c7afa2f754
commit
17d5acee9d
@ -1,4 +1,7 @@
|
||||
Public Class StringFunctions
|
||||
Imports System.Globalization
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class StringFunctions
|
||||
Public Shared Function SplitText_Length(ByVal input As String, ByVal maxLength As Integer) As List(Of String)
|
||||
Dim result As New List(Of String)
|
||||
|
||||
@ -19,4 +22,43 @@
|
||||
Dim lines As List(Of String) = text.Split({vbCrLf, vbLf, vbCr}, StringSplitOptions.None).ToList()
|
||||
Return lines
|
||||
End Function
|
||||
|
||||
Public Shared Function DatetimeStringToGermanStringConverter(pDatetimeString As String, pLogger As Logger) As String
|
||||
|
||||
If pDatetimeString.IsNullOrEmpty() = True Then
|
||||
' Wenn nichts kommt, kommt nichts zurueck
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
Dim formatList As List(Of String) = New List(Of String) From {
|
||||
"yyyyMMdd",
|
||||
"MM/dd/yyyy", "M/d/yyyy", "MM/d/yyyy", "M/dd/yyyy",
|
||||
"yyyy-MM-dd", "yyyy-M-d", "yyyy-MM-d", "yyyy-M-dd",
|
||||
"dd.MM.yyyy", "d.M.yyyy", "d.MM.yyyy", "dd.M.yyyy"
|
||||
}
|
||||
|
||||
Dim dateStringResult As Date = Date.MinValue
|
||||
Dim oConvertResult As Boolean = False
|
||||
|
||||
For Each formatStringItem In formatList
|
||||
Try
|
||||
dateStringResult = DateTime.ParseExact(pDatetimeString, formatStringItem, CultureInfo.InvariantCulture)
|
||||
oConvertResult = True
|
||||
Exit For
|
||||
Catch ex As FormatException
|
||||
oConvertResult = False
|
||||
pLogger?.Debug("DatetimeStringToGermanStringConverter() - Could not parse date string {0} ({1})", pDatetimeString, formatStringItem)
|
||||
End Try
|
||||
Next
|
||||
|
||||
If oConvertResult = True Then
|
||||
' In deutsches Format umwandeln (dd.MM.yyyy)
|
||||
Dim germanDateFormat As String = dateStringResult.ToString("dd.MM.yyyy")
|
||||
Return germanDateFormat
|
||||
Else
|
||||
' Wenn nichts konvertiert werden konnte, geben wir den ursprünglichen Wert zurück
|
||||
Return pDatetimeString
|
||||
End If
|
||||
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -215,7 +215,7 @@ Public Class XRechnungViewDocument
|
||||
Else
|
||||
'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS
|
||||
_logger.Debug($"FollowItem - Area: [{oArea}] - ItemSpecname: [{oItemSPECNAME}] - ItemValue: [{oItemValue}]")
|
||||
Dim otextBoxYPos As Integer
|
||||
'Dim otextBoxYPos As Integer
|
||||
If oArea = "POSITION" Then
|
||||
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
|
||||
oPosCount += 1
|
||||
@ -295,9 +295,7 @@ Public Class XRechnungViewDocument
|
||||
oItemValue = oPosTerm
|
||||
ElseIf oArea = "HEAD" Then
|
||||
If oItemSPECNAME = "INVOICE_DATE" Or oItemSPECNAME = "INVOICE_SERVICE_DATE" Then
|
||||
Dim oDateString As String = oItemValue
|
||||
Dim oParsedDate As DateTime = DateTime.ParseExact(oDateString, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
|
||||
oItemValue = oParsedDate.ToString("dd.MM.yyyy")
|
||||
oItemValue = StringFunctions.DatetimeStringToGermanStringConverter(oItemValue, _logger)
|
||||
End If
|
||||
ElseIf oArea = "TAXPOS" Then
|
||||
If oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user