当前位置: 首页>>代码示例>>Java>>正文


Java Time类代码示例

本文整理汇总了Java中codeu.chat.util.Time的典型用法代码示例。如果您正苦于以下问题:Java Time类的具体用法?Java Time怎么用?Java Time使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Time类属于codeu.chat.util包,在下文中一共展示了Time类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInfo

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public ServerInfo getInfo() {
  try (final Connection connection = this.source.connect()) {
    Serializers.INTEGER.write(connection.out(), NetworkCode.SERVER_INFO_REQUEST);
    if (Serializers.INTEGER.read(connection.in()) == NetworkCode.SERVER_INFO_RESPONSE) {
      final Uuid version = Uuid.SERIALIZER.read(connection.in());
      final Time startTime = Time.SERIALIZER.read(connection.in());
      return new ServerInfo(version, startTime);
    } else {
      LOG.error("Response from server failed.");
    }
  } catch (Exception ex) {
    	System.out.println("ERROR: Exception during call on server. Check log for details.");
     LOG.error(ex, "Exception during call on server.");
  }
  return null;
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:18,代码来源:View.java

示例2: testReadLimited

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testReadLimited() {

  final Server relay = new Server(8, 1);

  final Uuid team = new Uuid(3);
  final byte[] secret = { 0x00, 0x01, 0x02 };

  assertTrue(relay.addTeam(team, secret));

  assertTrue(relay.write(team,
                         secret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(6), "Hello World", Time.now())));

  assertTrue(relay.write(team,
                         secret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(7), "Hello World... again", Time.now())));


  final Collection<Relay.Bundle> read = relay.read(team, secret, Uuid.NULL, 2);
  assertTrue(read.size() == 1);
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:27,代码来源:ServerTest.java

示例3: testWriteSuccess

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testWriteSuccess() {

  final Server relay = new Server(8, 8);

  final Uuid team = new Uuid(3);
  final byte[] secret = { 0x00, 0x01, 0x02 };

  assertTrue(relay.addTeam(team, secret));

  assertTrue(relay.write(team,
                         secret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(6), "Hello World", Time.now())));
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:17,代码来源:ServerTest.java

示例4: testAddConversation

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testAddConversation() {

  final User user = controller.newUser(userId, "user", Time.now());

  assertFalse(
      "Check that user has a valid reference",
      user == null);
  assertTrue(
      "Check that the user has the correct id",
      Uuid.equals(user.id, userId));

  final ConversationHeader conversation = controller.newConversation(
      conversationId,
      "conversation",
      user.id,
      Time.now());

  assertFalse(
      "Check that conversation has a valid reference",
      conversation == null);
  assertTrue(
      "Check that the conversation has the correct id",
      Uuid.equals(conversation.id, conversationId));
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:26,代码来源:RawControllerTest.java

示例5: testFromUserToCreator

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testFromUserToCreator(){
	final User user = controller.newUser(userId, "user", Time.now());

	final ConversationHeader conversation = controller.newConversation(
       conversationId,
       "conversation",
       user.id,
       Time.now());

       conversation.userCategory.put(userId, 1);

       assertTrue(
    	"Check that the user is already in the conversation",
    	conversation.userCounter() == 1);

       assertTrue("Check that the user is currently a user",
       	conversation.userCategory.get(userId) == 1); 

}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:21,代码来源:ControllerTest.java

示例6: read

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public Relay.Bundle read(InputStream in) throws IOException {

  final Uuid id = Uuid.SERIALIZER.read(in);
  final Time time = Time.SERIALIZER.read(in);
  final Uuid team = Uuid.SERIALIZER.read(in);
  final Relay.Bundle.Component user = COMPONENT_SERIALIZER.read(in);
  final Relay.Bundle.Component conversation = COMPONENT_SERIALIZER.read(in);
  final Relay.Bundle.Component message = COMPONENT_SERIALIZER.read(in);

  return new Relay.Bundle() {
    @Override
    public Uuid id() { return id; }
    @Override
    public Time time() { return time; }
    @Override
    public Uuid team() { return team; }
    @Override
    public Relay.Bundle.Component user() { return user; }
    @Override
    public Relay.Bundle.Component conversation() { return conversation; }
    @Override
    public Relay.Bundle.Component message() { return message; }
  };
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:26,代码来源:ServerFrontEnd.java

示例7: testReadFailMissingTeam

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testReadFailMissingTeam() {

  final Server relay = new Server(8, 8);

  final Uuid team = new Uuid(3);
  final Secret secret = new Secret((byte)0x00, (byte)0x01, (byte)0x02);

  assertTrue(relay.addTeam(team, secret));

  assertFalse(relay.write(new Uuid(33),
                          secret,
                          relay.pack(new Uuid(4), "User", Time.now()),
                          relay.pack(new Uuid(5), "Conversation", Time.now()),
                          relay.pack(new Uuid(6), "Hello World", Time.now())));
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:17,代码来源:ServerTest.java

示例8: testReadLimited

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testReadLimited() {

  final Server relay = new Server(8, 1);

  final Uuid team = new Uuid(3);
  final Secret secret = new Secret((byte)0x00, (byte)0x01, (byte)0x02);

  assertTrue(relay.addTeam(team, secret));

  assertTrue(relay.write(team,
                         secret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(6), "Hello World", Time.now())));

  assertTrue(relay.write(team,
                         secret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(7), "Hello World... again", Time.now())));


  final Collection<Relay.Bundle> read = relay.read(team, secret, Uuid.NULL, 2);
  assertTrue(read.size() == 1);
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:27,代码来源:ServerTest.java

示例9: testWriteFailWrongSecret

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testWriteFailWrongSecret() {

  final Server relay = new Server(8, 8);

  final Uuid team = new Uuid(3);
  final Secret secret = new Secret((byte)0x00, (byte)0x01, (byte)0x02);
  final Secret wrongSecret = new Secret((byte)0x00, (byte)0x01, (byte)0x03);

  assertTrue(relay.addTeam(team, secret));

  assertFalse(relay.write(team,
                         wrongSecret,
                         relay.pack(new Uuid(4), "User", Time.now()),
                         relay.pack(new Uuid(5), "Conversation", Time.now()),
                         relay.pack(new Uuid(6), "Hello World", Time.now())));
}
 
开发者ID:Pandarati,项目名称:CodeU-Summer-2017,代码行数:18,代码来源:ServerTest.java

示例10: getConversations

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public Collection<Conversation> getConversations(Time start, Time end) {

  final Collection<Conversation> conversations = new ArrayList<>();

  try (final Connection connection = source.connect()) {

    Serializers.INTEGER.write(connection.out(), NetworkCode.GET_CONVERSATIONS_BY_TIME_REQUEST);
    Time.SERIALIZER.write(connection.out(), start);
    Time.SERIALIZER.write(connection.out(), end);

    if (Serializers.INTEGER.read(connection.in()) == NetworkCode.GET_CONVERSATIONS_BY_TIME_RESPONSE) {
      conversations.addAll(Serializers.collection(Conversation.SERIALIZER).read(connection.in()));
    } else {
      LOG.error("Response from server failed.");
    }
  } catch (Exception ex) {
    System.out.println("ERROR: Exception during call on server. Check log for details.");
    LOG.error(ex, "Exception during call on server.");
  }

  return conversations;
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:24,代码来源:View.java

示例11: getMessages

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public Collection<Message> getMessages(Uuid conversation, Time start, Time end) {

  final Conversation foundConversation = model.conversationById().first(conversation);

  final List<Message> foundMessages = new ArrayList<>();

  Message current = (foundConversation == null) ?
      null :
      model.messageById().first(foundConversation.firstMessage);

  while (current != null && current.creation.compareTo(start) < 0) {
    current = model.messageById().first(current.next);
  }

  while (current != null && current.creation.compareTo(end) <= 0) {
    foundMessages.add(current);
    current = model.messageById().first(current.next);
  }

  return foundMessages;
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:23,代码来源:View.java

示例12: pack

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public Relay.Bundle.Component pack(final Uuid id,
                                   final String text,
                                   final Time time) {

  return new Relay.Bundle.Component() {
    @Override
    public Uuid id() { return id; }

    @Override
    public Time time() { return time; }

    @Override
    public String text() { return text; }
  };
}
 
开发者ID:Pandarati,项目名称:CodeU-Summer-2017,代码行数:17,代码来源:NoOpRelay.java

示例13: testReadFailWrongSecret

import codeu.chat.util.Time; //导入依赖的package包/类
@Test
public void testReadFailWrongSecret() {

  final Server relay = new Server(8, 8);

  final Uuid team = new Uuid(3);
  final byte[] secret = { 0x00, 0x01, 0x02 };
  final byte[] wrongSecret = { 0x00, 0x01, 0x00 };

  assertTrue(relay.addTeam(team, secret));

  assertFalse(relay.write(team,
                          wrongSecret,
                          relay.pack(new Uuid(4), "User", Time.now()),
                          relay.pack(new Uuid(5), "Conversation", Time.now()),
                          relay.pack(new Uuid(6), "Hello World", Time.now())));
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:18,代码来源:ServerTest.java

示例14: read

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public Relay.Bundle.Component read(InputStream in) throws IOException {

  final Uuid id = Uuid.SERIALIZER.read(in);
  final String text = Serializers.STRING.read(in);
  final Time time = Time.SERIALIZER.read(in);

  // I could have passed the relay and use its "pack" method but that would
  // have been more work than just building an object here.
  return new Relay.Bundle.Component() {
    @Override
    public Uuid id() { return id; }
    @Override
    public String text() { return text; }
    @Override
    public Time time() { return time; }
  };
}
 
开发者ID:Pandarati,项目名称:CodeU-Summer-2017,代码行数:19,代码来源:ServerFrontEnd.java

示例15: newConversation

import codeu.chat.util.Time; //导入依赖的package包/类
@Override
public ConversationHeader newConversation(Uuid id, String title, Uuid owner, Time creationTime) {

  final User foundOwner = model.userById().first(owner);

  ConversationHeader conversation = null;

  if (foundOwner != null && isIdFree(id)) {
    conversation = new ConversationHeader(id, owner, creationTime, title);
    model.add(conversation);
    LOG.info("Conversation added: " + id);
  }

  return conversation;
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:16,代码来源:Controller.java


注:本文中的codeu.chat.util.Time类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。