Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java - SimpleDateFormat(ting) for XML
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Title of this code //'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_45 import java.util.*; import java.lang.*; import java.text.SimpleDateFormat; class Rextester { public static void main(String args[]) { System.out.println("START"); Date myDate = new Date(); String[] formats = new String[] { "yyyyMMdd", "yyyy-MM-dd", "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH:mmZ", "yyyy-MM-dd HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ", }; for (String format : formats) { SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); System.out.format("%30s %s\n", format, sdf.format(myDate)); //sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //System.out.format("%30s %s\n", format, sdf.format(myDate)); } //Simple System.out.println("\n" + new SimpleDateFormat("yyyy-MM-dd",Locale.US).format(new Date())); System.out.println("END"); } }
[
+
]
Show input
edit mode
|
history
|
discussion