diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-04-07 14:42:40 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-04-07 14:42:40 +0000 |
commit | 2c60951ba0efef23e2b765964b5dc0f1f49438a9 (patch) | |
tree | d96801a16fdf03a5682ef98730fe333a46eef944 /libjava/java/util/natDate.cc | |
parent | 1135eed2207f8f82c589e42ce113a1c2f0310778 (diff) | |
download | ppe42-gcc-2c60951ba0efef23e2b765964b5dc0f1f49438a9.tar.gz ppe42-gcc-2c60951ba0efef23e2b765964b5dc0f1f49438a9.zip |
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26263 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/natDate.cc')
-rw-r--r-- | libjava/java/util/natDate.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libjava/java/util/natDate.cc b/libjava/java/util/natDate.cc new file mode 100644 index 00000000000..27f91f6fa19 --- /dev/null +++ b/libjava/java/util/natDate.cc @@ -0,0 +1,45 @@ +/* Copyright (C) 1998, 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include <config.h> + +// We want to make sure to pick up the POSIX ctime_r. Some systems, +// such as Solaris 2.6, have their own version as well. +#ifdef HAVE_CTIME_R +#define _POSIX_PTHREAD_SEMANTICS +#endif + +#include <cni.h> +#include <java/util/Date.h> +#include <java/lang/String.h> + +#include <time.h> + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif + +jstring +java::util::Date::toString() +{ +#ifdef HAVE_CTIME_R + time_t t = millis / 1000; + char buf[30]; + return JvNewStringLatin1 (ctime_r (&t, buf)); +#elif defined (HAVE_CTIME) + // FIXME: this isn't thread-safe. + time_t t = millis / 1000; + return JvNewStringLatin1 (ctime (&t)); +#else + return NULL; +#endif +} |