Java tutorial
/* * Copyright 2015 Network New Technologies Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.networknt.light.server; import com.fasterxml.jackson.databind.ObjectMapper; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * Created by steve on 21/12/14. */ public class DbServiceTest extends TestCase { ObjectMapper mapper = new ObjectMapper(); public DbServiceTest(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(DbServiceTest.class); return suite; } public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testDateFormat() throws Exception { String dateString = "2014-11-30T05:00:00.000Z"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); try { Date strToDate = format.parse(dateString); System.out.println(strToDate); } catch (ParseException e) { e.printStackTrace(); } } }