01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.tests;
20:
21: import java.nio.ByteBuffer;
22: import java.nio.CharBuffer;
23: import java.nio.charset.Charset;
24: import java.text.SimpleDateFormat;
25: import java.util.Calendar;
26:
27: public class EncondingTest {
28: public static void main(String[] args) throws Exception {
29: String input = "k,føæakdføaækdfæ'a";
30: CharBuffer cb = CharBuffer.wrap(input.toCharArray());
31: ByteBuffer bf = Charset.forName("UTF8").encode(cb);
32: System.out.println(bf.asCharBuffer().toString());
33: System.setProperty("file.encoding", "UTF-8");
34: System.out.println(Charset.defaultCharset().displayName());
35: // System.out.println(new BufferedReader(new InputStreamReader( new
36: // ByteArrayInputStream("abcdæ".getBytes()))).readLine());
37: // java.text.DateFormat df =
38: // java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL,
39: // java.text.DateFormat.FULL);
40: String s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
41: .format(Calendar.getInstance().getTime());
42: if (s.charAt(s.length() - 2) != ':')
43: s = s.substring(0, s.length() - 2) + ":"
44: + s.substring(s.length() - 2);
45: System.out.println(s);
46: // Charset.defaultCharset().decode(new ByteBuffer("abcdæ".getBytes()));
47: }
48: }
|