Reputation: 101
I'm using an XSL to transform one XML into another. My problem is that in one element I have to display the current date with the format:YYYYMMDD.
I tried using a variable like these:
<xsl:variable name="dateNow" select="current-dateTime()"/>
<xsl:variable name="dateNow2" select="current-date()"/>
And then tried to format then, but no success.
<FRUEHESTER_LIEFERTERMIN><xsl:value-of select="format-dateTime($dateNow, '[Y0001][M01][D01]')"/></FRUEHESTER_LIEFERTERMIN>
Upvotes: 2
Views: 52598
Reputation: 11
If you want to show date in the following format Wed, 27-Oct
Use following code in XML
<TextClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="EE, dd-MMM"
android:textColor="@color/gray_100"
android:textSize="15sp"
android:layout_gravity="center"
android:padding="5dp"
android:textStyle="bold" />
If you want to show time like 09:08
Use the following code in XML
<TextClock
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:format12Hour="hh:mm"
android:textColor="@color/gray_100"
android:textSize="60sp" />
if you want to show time with AM and PM use following code in XML
<TextClock
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:format24Hour="HH:mm"
android:textColor="@color/gray_100"
android:textSize="60sp" />
Upvotes: 0
Reputation: 631
What exactly is happening (what does "no success" mean). What XSLT processor are you using?
Here is a minimal test case of what you are trying to do (input XML document doesn't matter)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="dateNow" select="current-dateTime()"/>
<xsl:variable name="dateNow2" select="current-date()"/>
<xsl:template match="/">
<FL><xsl:value-of select="format-dateTime($dateNow, '[Y0001][M01][D01]')"/></FL>
</xsl:template>
</xsl:stylesheet>
and here is what it produces -- do you get the same if you try this test case?
<?xml version="1.0" encoding="UTF-8"?>
<FL>20120111</FL>
Upvotes: 4