
com.nwalsh.xalan.CVS Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docbook-xsl-xalan Show documentation
Show all versions of docbook-xsl-xalan Show documentation
These are Java extensions for use with the DocBook XML stylesheets and the Xalan-Java XSLT engine.
The newest version!
package com.nwalsh.xalan;
import java.io.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.text.DateFormat;
import java.text.ParseException;
/**
* Xalan extension to convert CVS date strings into local time
*
* $Id: CVS.java 5932 2006-05-04 13:23:51Z nwalsh $
*
* Copyright (C) 2000 Norman Walsh.
*
* This class provides a
* Xalan
* extension to turn the CVS date strings, which are UTC:
*
* $Date: 2000/11/09 02:34:20 $
*
* into legibly formatted local time:
*
* Wed Nov 08 18:34:20 PST 2000
*
* (I happened to be in California when I wrote this documentation.)
* Change Log:
*
* - 1.0
* Initial release.
*
*
* @author Norman Walsh
* [email protected]
*
* @version $Id: CVS.java 5932 2006-05-04 13:23:51Z nwalsh $
*
*/
public class CVS {
/**
* Constructor for CVS
*
* All of the methods are static, so the constructor does nothing.
*/
public CVS() {
}
/**
* Convert a CVS date string into local time.
*
* @param cvsDate The CVS date string.
*
* @return The date, converted to local time and reformatted.
*/
public String localTime (String cvsDate) {
// A cvsDate has the following form "$Date: 2006-05-04 22:23:51 +0900 (Thu, 04 May 2006) $"
if (!cvsDate.startsWith("$Date: ")) {
return cvsDate;
}
String yrS = cvsDate.substring(7,11);
String moS = cvsDate.substring(12,14);
String daS = cvsDate.substring(15,17);
String hrS = cvsDate.substring(18,20);
String miS = cvsDate.substring(21,23);
String seS = cvsDate.substring(24,26);
TimeZone tz = TimeZone.getTimeZone("GMT+0");
GregorianCalendar gmtCal = new GregorianCalendar(tz);
try {
gmtCal.set(Integer.parseInt(yrS),
Integer.parseInt(moS)-1,
Integer.parseInt(daS),
Integer.parseInt(hrS),
Integer.parseInt(miS),
Integer.parseInt(seS));
} catch (NumberFormatException e) {
// nop
}
Date d = gmtCal.getTime();
return d.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy